You're almost certainly getting no answers because your question is vague and confused. Please read "How (Not) To Ask A Question" and try to explain your problem in more detail.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
As the previous posters indicate, we're forced to do a bit of guessing as to what you want. I'm guessing you want to save the data to disk and retrieve it again. Below is code to write your data to a flat file, then read it. Two things to note.
1.) Since there are newlines in the data, you can't use newline to separate fields on the disk. If your data is all printable ascii, you can use a non-printable char other then newline to separate items. Assign this to "$/" to get Perl to do the work for you.
2.) The 3 argument version of split() is less common, but very useful to know. In the case below, it splits into 2 fields only, so you just pull off the first field, the key, leaving all the separators in the second field in place.
my $blank = ' ';
my $fldSep = "\x1c";
my $recSep = "\x1e";
my $SAV;
my $RETRIEVE;
open $SAV, '>', 'tempsav.hsh' or die "Can't open save file";
store_rec($VAR1);
store_rec($VAR2);
close $SAV;
sub store_rec {
my $hashRef = shift;
my ($key,$val);
while (($key,$val) = each %$hashRef) {
$val = '' if !defined $val;
# guard against non=printing fld/rec sep in values
$val =~ s/$fldSep/?/g;
$val =~ s/$recSep/?/g;
print $SAV "$key $val$recSep";
}
print $SAV $fldSep;
1;
} # store
open $RETRIEVE, '<', 'tempsav.hsh' or die "Can't open save file";
$/ = $recSep;
while (<$RETRIEVE>) {
my ($key,$val);
$_ =~ s/$recSep$//;
for my $fld (split $fldSep, $_) {
($key,$val) = split(' ',$fld,2);
# Remove rec sep in values
print "$key => |$val|\n";
}
}
close $RETRIEVE;
By the way, I'm sure what you meant to say to daveorg was "Oops, here's what I meant...", since no one wants to help someone who dismisses those they have asked for help. If you still think you said what you meant, then you probably should swallow your pride, calm down, and read the other replies, since their advice will be far more valuable in the long run then the coding suggestions I've offered you above.
Good luck. | [reply] [d/l] |
| [reply] |
"A table"? You'll have to be more specific than that.
If you mean a database table, take a look at DBI.
If you mean printable plain text reports, take a look at perlform.
If you mean html tables or something similar, you can use one of the many template modules.
etc...
| [reply] |
| [reply] |