djbiv has asked for the wisdom of the Perl Monks concerning the following question:
Here is a sample file, note that where the key 48 in the file and below is where I would like the data read into an embedded hash, any help would be great!:sub rd_template { my (%mymsg, %msg48, $msg, $key, $val, $msg48, $key48, $val48); open FH, $opt_f or die "Can't open $opt_f: $!"; while (<FH>) { chomp; ($key, $val) = split /=>/; if ($key == 48) { ($key48, $val48) = split /=>/; $msg48{$key48} = $val48; } $msg{$key} = $val; } close FH or die "Can't close $opt_f: $!"; my @temp = %msg; # testing to see the hash quickly.. print "@temp\n"; }
MTI=>1100 2=>4000000000000001 3=>003000 4=>000000010000 11=>666666 12=> 14=>0404 22=>B00101200041 24=>100 41=>0009 42=>0009000101 48=> 2=>01 02 3=>5555555
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash in a hash value
by halley (Prior) on Jun 03, 2003 at 17:28 UTC | |
|
Re: Hash in a hash value
by pzbagel (Chaplain) on Jun 03, 2003 at 18:02 UTC | |
by Anonymous Monk on Jun 03, 2003 at 18:15 UTC |