in reply to Include external variables into script

require should work, but you might want to check out something like AppConfig for a much more robust and flexible config file system.
require '/tmp/b'; print $x; # 3 # assuming /tmp/b has $x=3; in it
Update: Actually, above was working for me only w/o 'use strict'.

Wasn't going to mention it originally cause it can be BAD, but you can also read in the whole config file and eval, but as recently discussion in the last week or two, this can be BAD.

Update 2: A quick AppConfig example:
use strict; use warnings; use AppConfig; my $config = AppConfig->new({ GLOBAL => { DEFAULT => "<undef>", ARGCOUNT => AppConfig::ARGCOUNT_ONE, } }, "var1", "var2"); $config->file(\*DATA); print $config->var1() , "\n"; print $config->var2() , "\n"; __DATA__ var1 = x var2 = y

Replies are listed 'Best First'.
Re^2: Include external variables into script
by Mur (Pilgrim) on May 25, 2005 at 12:55 UTC
    Just "seconding" the suggestion ... AppConfig is one of those modules that, once you learn how to use it, you'll never have to solve such problems again.
    --
    Jeff Boes
    Database Engineer
    Nexcerpt, Inc.
    vox 269.226.9550 ext 24
    fax 269.349.9076
     http://www.nexcerpt.com
    ...Nexcerpt...Connecting People With Expertise