[EMAIL PROTECTED] wrote:
I need to include a header/boilerplate file in several Perl scripts.
At this point, I'm using it as a module, but it's a big kludge. Essentially,
 I want the functionality that you have in C, where you can just #include
the file, and it's evaluated in the scope of the file doing the #include'ing.

I've considered using:
    do "<file>";
but it just doesn't seem to be the best solution. This header file needs
to do operations in the main:: namespace (like getting command line arguments,
 etc), which is why doing it as a module is not working too well. Does
anybody have any suggestions?

Please reply directly to me. I am not subscribed to the list.

There are 4 ways to do what you want. The closest is probably 'do'


perldoc -f do

I would recommend the module approach as has already been suggested:

perldoc -f use
perldoc -f require

At a lower level, you can read the file into a scalar and 'eval' it:

perldoc -f eval


Regards, Randy.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to