Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing data to the perl program that is running

Status
Not open for further replies.

jackz15

Programmer
Joined
Jun 28, 2006
Messages
103
Location
US
I'm making a calulator which stores functions along with its operators in a hash, the user can even create their own functions. But the problem is that the functions dissappear after the program exists, one thing i could do, like i did for storing user create variables, i could save the operations in another file and then upload it into the program when the program starts. But having two separate files to save is a bit of a hassle and its much better to just add the function into the operations hash in my program. But I can't figure out how one could do that, can someone lend me a hand?
 
You can store data at the end of your program, after the __END__ or __DATA__ marker, and read it using the filehandle DATA when the program starts. You can write to the program file using normal file-handling methods.

However, programs are normally made read-only, for security reasons. You might want to consider that aspect.
 
that is true... perhaps i'll just make another file
 
Use the "storable" module to save your data structures to file to make them persistent.
 
storable would be the direction I'd be investigating

Mike

The options are: fast, cheap and right - pick any two. [orientalbow]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top