LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl variables (https://www.linuxquestions.org/questions/programming-9/perl-variables-111129/)

nbp 11-01-2003 11:09 AM

Perl variables
 
When a perl script exits, all the variables associated with it are lost. Is there a way of saving these variables for access by other scripts ?

acid_kewpie 11-01-2003 11:34 AM

in what sense do you want these accessible? you can always do something like using Data::Dumper to print out any data structures to a file to read later... if you want a more temporary method on only a couple of variables, try exporting them to bash

dkloes 11-02-2003 09:33 AM

Since you can only export to subsequent shells, here are some things to look at:

1. Source the script instead of having a separate shell
execute it. i.e. . scriptname
2. Have your script run the command that needs the environment
variables
3. Save the value of the variable to a file and then read the file in the previous script using: var=`cat filename`
This would be cumbersome if multiple people were running the script because the filename would need to be unique for a user.


All times are GMT -5. The time now is 05:17 AM.