in reply to reading textfiles into 1 whole file
my @files=<*.text>;#scans for .txt extensn in the curent dir local @_=@files; foreach my $file(<>)
The @_ array has no relation to the special <> readline operator so your program is reading all lines from all files listed in the @ARGV array, or from STDIN if @ARGV is empty and storing them in a list in memory and then iterating over them from that list and the files listed in @files are ignored.
If you want to use <> you have to store your file names in @ARGV and you should probably also use a while loop instead of a foreach loop:
local @ARGV = <*.text>;#scans for .txt extensn in the curent dir while ( my $line = <> )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading textfiles into 1 whole file
by luckysing (Novice) on Jul 13, 2010 at 07:53 UTC |