in reply to Re: opening many files
in thread opening many files

open my $fds[$_], '<', "datafile$_" or die $!;

You can't use my on an array element.



my $line = <$fds[$fdn]>;

From I/O Operators:

If what's within the angle brackets is neither a filehandle nor a simple scalar variable containing a filehandle name, typeglob, or typeglob reference, it is interpreted as a filename pattern to be globbed, and either a list of filenames or the next filename in the list is returned, depending on context. This distinction is determined on syntactic grounds alone. That means "<$x>" is always a readline() from an indirect handle, but "<$hash{key}>" is always a glob(). That's because $x is a simple scalar variable, but $hash{key} is not--it's a hash element. Even "<$x >" (note the extra space) is treated as "glob("$x ")", not "readline($x)".

Replies are listed 'Best First'.
Re^3: opening many files
by aaron_baugher (Curate) on Feb 27, 2012 at 01:18 UTC

    Well, I did say it was untested, but that's a poor excuse. ++ for the correction; my 'my' should be removed on that line.

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.