Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: include statement in perl?

by BrowserUk (Patriarch)
on May 31, 2003 at 02:48 UTC ( [id://262018]=note: print w/replies, xml ) Need Help??


in reply to include statement in perl?

Update Corrected @ARGV to *ARGV to correct the error noted by Aristotle++ below.

use strict; use warnings; use CGI; .... print do{ local (*ARGV,$/), @ARGV='files/my.html'; <> }; # Hic! ....

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Replies are listed 'Best First'.
Re^2: include statement in perl? (idiom with caveats)
by Aristotle (Chancellor) on May 31, 2003 at 03:16 UTC

    Just be careful that the ARGV filehandle is not currently open on another file, otherwise it won't quite do what you expected.

    Update: localizing the entire *ARGV glob works, but doesn't work in less than recent Perls - it breaks on less than 5.8, IIRC 5.6 - see (tye)Re: Cheap idioms.

    Makeshifts last the longest.

      If it's good enough for tye, it's good enough for me:)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Log In?
Username:
Password:

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

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

    No recent polls found