467,081 Members | 1,150 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,081 developers. It's quick & easy.

Accessing a variable in one perl script from the other


I am completely new to Perl. I am trying to access a variable in one of my Perl scripts from a 2nd perl script.

The 1 st script uses a file and extracts some data and manipulates the data and assigns the variable $p with some value.

Now after the 1 st script has been executed I want the value of $p in my 2nd script. Is that possible?? Please let me know how to access this value of $p.

Sep 30 '08 #1
  • viewed: 1547
2 Replies
Expert 2GB
If script one runs and ends, then you run script two, the values in script one are gone. You would have to write them to disk, text file or database, to make them persistent. Otherways to include external perl scripts in your script is via "do" or "require". You can look those up in the perl documentation.
Sep 30 '08 #2
Expert 100+
Kevin is correct in many ways.


running the second perl script by:

First Script:
Expand|Select|Wrap|Line Numbers
  1. system("perl script.pl $p");

Second Script:
Expand|Select|Wrap|Line Numbers
  1. foreach (@ARGV) { 
  2. $p=@ARGV[0];
  3. }

this is untested but may work.
Sep 30 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Julia Bell | last post: by
2 posts views Thread by pleaseexplaintome@yahoo.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.