in reply to Writing many lines to a file
First of all, 100 lines is a small file, not a big one ;-)
If you just need to copy the file and do something to every line, this might be something similar to what you want (untested, written from memory):
#!/usr/bin/env perl use strict; use warnings; open(my $ifh, '<', 'infile.txt') or die($!); open(my $ofh, '>', 'outfile.txt') or die($!); while((my $line = <$ifh>)) { chomp $line; # do something to $line print $ofh $line, "\n"; } close($ifh); close($ofh);
If you really just want to copy a file, you can use File::Copy:
#!/usr/bin/env perl use strict; use warnings; use File::Copy; copy('infile.txt', 'outfile.txt') or die("Ooops, i messed up: $!");
|
|---|