Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Indirect Referencing

by Roy Johnson (Monsignor)
on Jun 17, 2004 at 14:02 UTC ( [id://367621]=note: print w/replies, xml ) Need Help??


in reply to Indirect Referencing

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.
You can try the readline function rather than the <> operator. It is not clear to me whether you get all the default behaviors when using readline.

We're not really tightening our belts, it just feels that way because we're getting fatter.

Replies are listed 'Best First'.
Re^2: Indirect Referencing
by periapt (Hermit) on Jun 17, 2004 at 14:35 UTC
    Darn, I missed that. I'm not hung up on using the hash element, I just got running down the wrong track. Thanks.

    PJ
    We are drowning in information and starving for knowledge - Rutherford D. Rogers
    What good is knowledge if you have to pull teeth to get it - anonymous
Re^2: Indirect Referencing
by Aragorn (Curate) on Jun 17, 2004 at 20:50 UTC
    Update: Argh! Nevermind, I misunderstood the question.
    If what's within the angle brackets is neither a filehandle nor a simple scalar variable containing a filehandle name, typeglob, or typeglob reference,
    $infh is a typeglob reference, so it should work. Actually, it does, if the while(<$infh}>){ is replaced by while(<$infh>){.

    Small change, big results ;-)

    Arjen

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-28 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found