By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,168 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,168 IT Pros & Developers. It's quick & easy.

Bulk loading into file in PERL

P: 1
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....

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..

Dec 27 '06 #1
Share this Question
Share on Google+
2 Replies

P: 83
What do you want to achieve? If memory consumption is a concern, line by line appending is preferrable.
Dec 27 '06 #2

P: 83
You can always do:
Expand|Select|Wrap|Line Numbers
  1. open my $f1, '<', 'file1' or die "Couldn't open file1: $!";
  2. open my $f2, '>', 'file2' or die "Couldn't open file2: $!";
  4. while ( read $f1, my $tmp, 131072 ) {
  5.     $tmp =~ s/OLDVALUE/NEWVALUE/g;
  6.     print $f2 $tmp;
  7. }
OTOH, that does not prevent "some value" from being split between two chunks...
Dec 27 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.