in reply to File read and strip
Will set $file to the first line (including the newline) read from either STDIN or the file specified on the command line. This is almost certainly not what you want.my $file=<>;
You probably want
Which, outside of subroutines can be abbreviated tomy $file = shift @ARGV; # get first argument my $nfile = shift @ARGV; # get next argument
or you can usemy $file = shift; my $nfile = shift;
By the way, it's always a good idea to check open() for errors:my ($file,$nfile) = @ARGV;
update: there are other errors in your code, too. Note that grep() returns a LIST, for one.open FILE,">$file" or die "Can't open $file: $!"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File read and strip
by Andrew_Levenson (Hermit) on Nov 14, 2006 at 19:56 UTC | |
by Joost (Canon) on Nov 14, 2006 at 20:11 UTC | |
|
Re^2: File read and strip
by Andrew_Levenson (Hermit) on Nov 14, 2006 at 19:54 UTC | |
by Joost (Canon) on Nov 14, 2006 at 20:03 UTC | |
by runrig (Abbot) on Nov 14, 2006 at 20:12 UTC |