For those who are interested... This seems to work but I don't know why: foreach $element (@elements) { my $profile = MY_PROFILE->new(); $profile = eval(eval(Dumper($element))); push(@profileArray,$profile); }
On Wednesday, July 31, 2002, at 11:51 AM, todd shifflett wrote: > I am having trouble re-reading a record after I write it. > > This is my situation (I'll try and be as concise as possible): > > > I have an object ($profile) with methods, variables, and variables of > other objects. > For example: > $profile = MY_PROFILE->new(); > $profile->{NAME} = "theName"; > $profile->{ARRAY} = [MY_OBJECT->new(), MY_OBJECT->new(), ...]; > $profile->myFunction(); # calls a method of MY_PRIOFILE > > > I then use Data::Dumper to write out a file with a header and an array > of profiles: > $Data::Dumper::Purity = 1; > $Data::Dumper::Indent = 0; > my $header = {DATE => "${year}\.${month}\.${day}"}; > open RECORD, ">$fileName"; > print RECORD Data::Dumper->Dump([$header], ["*header"]); > close RECORD; > foreach my $profile (@profileArray) { > $profile->myFunction(); > open RECORD, ">>$fileName"; > print RECORD Data::Dumper->Dump([\$profile], ['*profile']); > close RECORD; > } > > when I read the file I can regenerate the header: > > open RECORDFILE, "<", $inFile; > my @elements = split(";",<RECORDFILE>); > close RECORDFILE; > my $element = shift(@elements); > eval $element; > $header = \%header; > > however I cannot recreate the MY_PROFILE object with: > > foreach $element (@elements) { > my $profile = MY_PROFILE->new(); > eval $element; > push(@profileArray,$profile); > } > > is there anyone that can help? Am I being at all clear? > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]