I am creating a script for a company. It is going to be run on an NT server with active Perl on it. I have no access to this server to add the Storage.pm onto it.
I am trying to save a hash to a file then read it back exactly the same.
#this is only one line. I split it to fit on the page
$newLine = "<B><font color=$color>$topic</B>:$Timeis<BR>$posting<BR>--
+By
$person<BR><BR><!-- $postip --></font>\n";
#This is what I have to read the file into my hash
if( -e "joe.txt"){
open(MYFILE, "joe.txt");
$mysize= -s MYFILE;
read(MYFILE, $mypage, $mysize);
close(MYFILE);
#I also just tried %hash = $mypage;
@myarray = split /\n/, $mypage;
foreach (@myarray){
%myhash = split /=>/, $_;
}
}
#This is how I add to my
$myhash{$timestamp}=$newLine;
#this is how I write out.
open(TESTFILE, ">$file2");
foreach (keys %myhash)
{
print TESTFILE "$_=>$myhash{$_}";
#this is for debugging
print "$_=>$myhash{$_}";
}
I think it might be something that I am not doing right but I can not see it. I have the => to separate each key from the value because of the spaces and \n s in the value. I have been pounding my head on my desk trying to get this to work. I am open to any and all suggestions with this.
Thanks for any information.
--Big Joe
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.