in reply to sourcing

You may be wanting something like this.

do "myfile";

That will read in the specified file as perl and execute it in place right then.

The camel says its like doing a require with an eval, but more efficient and gives file and line for errors. It will re read and reparse the entire file for each call so it is not that good in loops unless the file changes with each pass of the loop.

Replies are listed 'Best First'.
Re: Re: sourcing
by snafu (Chaplain) on Apr 02, 2002 at 15:20 UTC
    We just ran into a snag with this though. It doesn't work right (or at least we haven't been able to make it work right) with the use of strict. Any ideas on that?

    Update
    The way we fixed it was by explicitly making the sourced file a package:

    { package PACKAGE_NAME;do "sourced_file.pl" };

    and then we had to explicitly call each symbol by its package name in order to reference the data "inside" the symbol.

    print $PACKAGE_NAME::variable,"\n";

    Any other way we tried wouldn't work right *shrug*.

    _ _ _ _ _ _ _ _ _ _
    - Jim
    Insert clever comment here...