Solved

Perl's sessionobject...

Posted on 2000-03-27
7
157 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 16

Expert Comment

by:maneshr
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
"....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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now