Bulk loading into file in PERL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • its me Rock
    New Member
    • Dec 2006
    • 1

    Bulk loading into file in PERL

    Hi All,

    How to load bulk of records from one file to another file.Is there any memory allocation techiques available.Need suggestion in that....

    Eg:
    just reading the data from the file and changing some value and storing into another file .. It's happening for record by record .. But i want to insert bulk of record at the same time.


    any response appreciatable..

    Reg..
    --------
    Rock...
  • GunnarH
    New Member
    • Nov 2006
    • 83

    #2
    What do you want to achieve? If memory consumption is a concern, line by line appending is preferrable.

    Comment

    • GunnarH
      New Member
      • Nov 2006
      • 83

      #3
      You can always do:
      Code:
      open my $f1, '<', 'file1' or die "Couldn't open file1: $!";
      open my $f2, '>', 'file2' or die "Couldn't open file2: $!";
      
      while ( read $f1, my $tmp, 131072 ) {
      	$tmp =~ s/OLDVALUE/NEWVALUE/g;
      	print $f2 $tmp;
      }
      OTOH, that does not prevent "some value" from being split between two chunks...

      Comment

      Working...