in reply to $_[0] as a filehandle
You can't use subscripts in a variable used as a filehandle. This applies to the diamond operator as well as print statements. I.e. print $_[0] "foo"; won't work either.
Update: Here's the relevant bit from perldoc perlop:
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.
By the way, please test your example code before pasting it. Yours had several errors unrelated to the issue you are seeing.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: $_[0] as a filehandle
by jey (Pilgrim) on Oct 29, 2003 at 02:18 UTC |