People generally do
use strict; use warnings;
nowadays, and that's the single best piece of advice I can give you!
Also, people do
my @DATA=<ORIGFILE>;
but then they also prefer to avoid slurping in files all at once, and they iterate on the lines instead with a while loop rather than with a for one:
while (my $line=<ORIGFILE>) { # ...
In any case you have to specify '>' mode in open for writing (and '>>' for appending). More generally I recommend you to stick with the three args form of open and lexical handles, and always check the return value:
open my $in, '<', "whatever" or die "can't open `whatever': $!\n"; open my $out, '>', "whatever" or die "can't open `whatever': $!\n";
In reply to Re^3: Seperating individual lines of a file
by blazar
in thread Seperating individual lines of a file
by tgrossner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |