Hello...
I have just started using Perl because I wanted to use it for CGI..
I had been using Euphoria for stand-alone (http://www.rapideuphoria.com).
I am trying to create a tutorial type web site, where students log in and receive instruction, based on what they need help with. It seems I am stuck at the simplest part, so far..heh..
But, I have created a hash of hashes, which I was able to do by looking at um..i think it is perldocs.com. Anyway, I am now trying to save that hash of hashes to a file...the book i have (Teach yourself Perl in 24 hours) seems to imply that it is as easy as using
print FILEHANDLE @studentlist;
However, this isn't working..it is saving SOMETHING..but when I try to read back in (by using @studentlist=<FILEHANDLE>;)
I am getting something like
student1HASH(0x155efb4): { }
for the data that is read in.
Can someone give me a quick example of how to read/write hashes to a file?
There are several options.
1. Perl comes with a module, Storable, that can be used to read/write entire data structures easily:
use Storable; store \%data, 'file'; $hashref = retrieve('file');
2. If you have a larger data set and you only need to look at a subset of that data per run, you can use the MLDBM module:
use MLDBM; $dbm = tie %data, 'file';
Further up the list would be using a full blown database with the DBI::* modules, but the above is probably sufficient.
Regards, Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>