in reply to read/write perl variables to/from file
Hi, below I am using newlines to seperate variables. This is far from foolproof, but demonstrates what you asked for.
open FILE, ">filename" or die $!; print FILE $myVar, "\n"; close FILE; #... later on... open FILE, "filename" or die $!; $myVal = <FILE>; chomp $myVal; #remove the newline close FILE;
If you need to do more, look at Data::Dumper or Storable, both part of the core modules. They facilitate the serialization of complex data structures.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|