Including files (again)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've read the perl monks tutorial on including files and I think I understood
most of it. But I would still like to include a file, so I'm going to ask anyway

The file I'd like to include is sort of like an argument to the script - there
are a whole bunch of them and I'd I like to be able to say:
$ my-script.plx <file> <more arguments>
(Or more likely, in the shell:
$ for i in *some-pattern* ; do my-script.plx $i <further args> ; done)

Usually when I do this the file is very simple, but in this case it has
structure, so I coded that in perl like:

%hash1 = (fruits => ["apple", "pear"],
          things => ["table", "chair"]

%hash2 = (fruits => ["pear", "banana"]
          countries => ["Turkey"]

Using pure text and parsing it with split,... instead of Perl code seems like
quite a hassle I'd like to avoid.

Is there any way to do this in Perl? The one thing I didn't understand is what
"eval" does, and I couldn't get the syntax right. Does anyone have a hint for

I'd also welcome ideas on how to re-design this, if it's the case that I'm being
blind as to a much easier way ;-)

Re: Including files (again)

Quoted text here. Click to load it

    perldoc -q persist

        How do I keep persistent data across program calls?

Quoted text here. Click to load it

There are 2 wildly different Perl functions that are both named "eval".

The first question to answer is whether we are discussing "eval block"
or "eval string"...

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Site Timeline