pmonk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Fellow Monks: How can I get a value (say $source=123;) from find.pl into another script last.pl?

Replies are listed 'Best First'.
Re: importing values
by suaveant (Parson) on Aug 31, 2001 at 18:31 UTC
    commandline
    `last.pl $source`; #in last.pl my $source = $ARGV[0];
    you can put it in the environment... (only works if you call last.pl from find.pl)
    $ENV{SOURCE} = $source; `last.pl`; #in last.pl my $source = $ENV{SOURCE};
    pass it on STDIN
    open(LAST, "|last.pl") or die $!; print LAST "$source"; close LAST; #in last.pl $source = <STDIN>;
    Those are probably the easiest/best ways... there are other ways, such as using a file, passing over a socket, shared memory, creating a dynamic link to last.pl named for the value of source and running the dynamic link, and then reading the value of $0 in last.pl (don't do that one). Many many ways.

                    - Ant
                    - Some of my best work - Fish Dinner

Re: importing values
by jryan (Vicar) on Aug 31, 2001 at 18:24 UTC
    Use require:
    require "find.pl"; print $source;
Re: importing values
by claree0 (Hermit) on Aug 31, 2001 at 18:20 UTC

    pass it on the command line?

    Put the values into a file?

      the value $source is generated in my script called find.pl and I want to take that value and put it in another file called last.pl.
Re: importing values
by count0 (Friar) on Aug 31, 2001 at 18:31 UTC
    There are a great number of ways to do that.
    Perhaps the most common would be by passing the values during the execution of the script (at the command line in *nix).
    ./script.pl foo bar baz
    Now the values 'foo','bar', and 'baz' are available in @ARGV within script.pl as $ARGV[0], $ARGV[1], and $ARGV[2] repectively.

    If you haven't already, a good trip to the Library or a copy of "Programming Perl" (ORA - the camel) might come in really handy. =)