Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Newbie: uses/limits of perl in editing files

by Sixtease (Friar)
on Nov 23, 2007 at 14:13 UTC ( [id://652569]=note: print w/replies, xml ) Need Help??


in reply to Re: Newbie: uses/limits of perl in editing files
in thread Newbie: uses/limits of perl in editing files

Wow, I didn't know the print {$wfh} $line; construct. Does that disambiguate $wfh to be interpreted as a filehandle?

Replies are listed 'Best First'.
Re^3: Newbie: uses/limits of perl in editing files
by Fletch (Bishop) on Nov 23, 2007 at 14:40 UTC

    Yes; because the "filehandle argument slot" (for lack of a better name) has to be a simple scalar value or a BLOCK. While it's superfluous in this particular case the block form is useful if you (for instance) have a hash of filehandles and want to use print { $handles->{$somekey} } "Yadda yadda yadda.\n"; directly rather than pulling it out into a tmp variable. The docs for print cover this.

Re^3: Newbie: uses/limits of perl in editing files
by tirwhan (Abbot) on Nov 23, 2007 at 14:48 UTC

    Yep, I picked that up from thedamians Perl Best Practices (a must-read for every Perl programmer IMO). As Fletch rightly points out, it's not necessary in this case, but I just use it wherever I print to a filehandle (easier to do than figure out what's wrong if I ever forget it :-)


    All dogma is stupid.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-25 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found