Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Opening multiple files

by BrentDax (Hermit)
on May 30, 2006 at 08:21 UTC ( [id://552431]=note: print w/replies, xml ) Need Help??

in reply to Opening multiple files

It's possible, but it's a real hack, involving @ARGV and the magic <> construct. (I won't tell you how to do it because if you're not clever enough to find it with those hints, you're not clever enough to know not to use it.) You're really better off simply using a loop. The correct way to code that loop would probably be like this:

my @lines; foreach my $file(@files) { open(IN, "< $file") or die "Can't open $file: $!"; push @lines, <IN>; close IN; } # Now do whatever you want with @lines

Alternatively, remove all references to @lines and replace the push line with:

while(my $line = <IN>) { #Do whatever processing you want with $line }

Hope this helps,

--Brent Dax
There is no sig.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://552431]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-05-21 22:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found