Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Passing values between different scripts

by ajguitarmaniac (Sexton)
on Dec 28, 2010 at 15:30 UTC ( #879447=perlquestion: print w/ replies, xml ) Need Help??
ajguitarmaniac has asked for the wisdom of the Perl Monks concerning the following question:

Namaste Monks! This is somewhat like an extension to a question that I had posted earlier Array comparison using perl. In my previous question I'd used arrays

my @arr1 = ('1','2','3','4','5','6','7','8','9'); my @arr2 = ('1','4','5','9','7');
and sought help to run a comparison between the two. But now my requirement has changed in a way that @arr1 is in one script say and @arr2 in another script say, both scripts found in the same directory. I need to run the array comparison procedure (which was the solution to my former question) in and for this to occur @arr1 from must be called into It must be noted that the arrays do not contain predefined values as shown. Please help me out with this wise Monks! Thanks!

Comment on Passing values between different scripts
Select or Download Code
Replies are listed 'Best First'.
Re: Passing values between different scripts
by Corion (Pope) on Dec 28, 2010 at 15:38 UTC

    Write the array into a file, read it in the second script and output the comparison there.

    Or convert the second script to a module and use it in the first script.

      Thank you Corion. Two working options. I'm gonna try out and learn both. Thanks a lot. I'm very happy :-)

Re: Passing values between different scripts
by fisher (Priest) on Dec 28, 2010 at 15:42 UTC
    maybe using modules will save your time and nerves? You can put your arrays in module and use it from your two scripts. See Simple Module Tutorial.

      Looks like you've read right through me! Thanks a lot fisher :-)

Re: Passing values between different scripts
by JavaFan (Canon) on Dec 28, 2010 at 16:05 UTC
    Is calling If not, are both programs running at the same time? If not, does your question make any sense? If one script is calling the other, can't you just pass the array as parameters? Or else, use shared memory/a file/a database/a pipe/a socket to pass information back and forth. See man perlipc.
Re: Passing values between different scripts
by jethro (Monsignor) on Dec 28, 2010 at 15:40 UTC

    You could read in your into a string and use the eval function to execute it. But why would you want to do that? Is this school homework you are doing?

    The sensible thing would be to make into a module and use it just like a library from

      Thank you jethro!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://879447]
Approved by herveus
Front-paged by BrowserUk
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2015-10-09 16:10 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (244 votes), past polls