Solved

Perl's sessionobject...

Posted on 2000-03-27
7
193 Views
Last Modified: 2010-03-05
It is possible to store variables permanent between different
perliis-scripts?

Something like this
$GLOBAL::var = 123;

and then in another script write
print $GLOBAL::var;
0
Comment
Question by:perlman
7 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2661578
yes you can do that. how ever the scope of these variables would be across one transaction only (a transaction is from the time a script is executed till the time the results are returned).

On the other hand if you want to access a variable across 2 transactiosn you might want ot use cookies or store the info on the server end and then pass a reference to the info across transactions.

0
 
LVL 8

Expert Comment

by:jhurst
ID: 2662764
Files, especially dbm files:

dbmopen(%HASHNAME,"yourFile",0644);
$HASHNAME{variable}="whetever";

etc.

This same HASNAME will be availabel to all scripts that open the same file.



0
 

Author Comment

by:perlman
ID: 2663127
Thanks for the answer, didn't express
too clearly, I wonder if there was any
other way than the regular ways,
cookies, files, for example store
arrays or hashes in a "permanent memory". Impossible...?

Cookies works fine for small data,
and save to files works when its
not too many files, or too many or big
records in dbm.

I want to store a large size of data,
say 0.5 - 3 mb and could reach one of
the records with a key (like hashes and
no limits like dbm)

I read some about POE, maybe that was
a completly different thing?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:maneshr
ID: 2664316
since you mentioned about the large size of the data, what you could do is to store the data in your server (in some temp dir.) and pass the file where that data is stored across transactions (as a cookie or hidden form variable).

if you have a DB then you could store that same info as a CLOB data type which would have a sequence number associated with it.
Then you just pass that sequence number across transactions.

the final approach would depend on the no of transactions that you expect and the duration for which this large data should be available.

0
 

Author Comment

by:perlman
ID: 2664694
It's then impossible to store things in memory..?

I'm looking for a faster way than using
files and database storage. Like a
perlmodule that can store variables
in a "separate memory" that is not destroyed at the script's end.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2664874
Do you mean like Persistent::File or Data::Dumper or AnyDBM_File or Tie::Persistent?
0
 
LVL 16

Accepted Solution

by:
maneshr earned 80 total points
ID: 2665106
"....It's then impossible to store things in memory..? " ....."that is not destroyed at the script's end. ............"

not across transactions, unless you are using a specialized software (web app server) that would do it for you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question