LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-01-2003, 11:09 AM   #1
nbp
LQ Newbie
 
Registered: Oct 2003
Posts: 9

Rep: Reputation: 0
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 ?
 
Old 11-01-2003, 11:34 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
in what sense do you want these accessible? you can always do something like using Data:umper 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
 
Old 11-02-2003, 09:33 AM   #3
dkloes
Member
 
Registered: Oct 2003
Posts: 66

Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PERL: concatenation of variables issue randomx Programming 2 01-16-2005 04:52 PM
How to use session variables in perl ? taqs Programming 1 09-28-2004 06:12 PM
Environment variables and perl jrbiochem Linux - General 0 05-06-2004 09:40 AM
exporting variables in Perl nbp Programming 1 11-18-2003 08:35 AM
Environment variables Perl nbp Programming 1 10-28-2003 08:49 AM


All times are GMT -5. The time now is 08:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration