#!/usr/bin/perl --
use strict; use warnings;
use Data::Dump;
use Data::Diver qw/ DiveVal /;
open my $fh, '<', \q{Ho|001 -> ooB -> Ho.62
Ho|001 -> nom -> rapidqa
Ho|001|VAG|001 -> VAG -> 21.00.00.E0.8B.80.7E.7D
Ho|001|VAG|002 -> VAG -> 21.00.00.E0.8B.80.E7.7F
Ho|001|BigUnit|001 -> ooB -> LU.R700.87108.8234
Ho|001|BigUnit|001 -> deR -> 8234
Ho|001|BigUnit|002 -> ooB -> LU.R700.87108.8235
Ho|001|BigUnit|002 -> deR -> 8235
Ho|002 -> ooB -> Ho.107
Ho|002 -> nom -> sapfvir03
Ho|002|VAG|001 -> VAG -> 21.00.00.E0.8B.81.D7.F6
Ho|002|VAG|002 -> VAG -> 21.00.00.E0.8B.81.4C.F9
Ho|002|BigUnit|001 -> ooB -> LU.R700.87108.10336
Ho|002|BigUnit|001 -> deR -> 10336
};
my $root = {};
while(<$fh>){
s/\s+$//;
my( $left, $mid, $right ) = split ' -> ', $_;
my @paths = map { \$_ } split(/\|/, $left), $mid;
DiveVal( $root, @paths ) = $right;
}
dd $root;
__END__
{
Ho => {
"001" => {
BigUnit => {
"001" => { deR => 8234, ooB => "LU.R700.87108.8
+234" },
"002" => { deR => 8235, ooB => "LU.R700.87108.8
+235" },
},
nom => "rapidqa",
ooB => "Ho.62",
VAG => {
"001" => { VAG => "21.00.00.E0.8B.80.7E.7D" },
"002" => { VAG => "21.00.00.E0.8B.80.E7.7F" },
},
},
"002" => {
BigUnit => { "001" => { deR => 10336, ooB => "LU.
+R700.87108.10336" } },
nom => "sapfvir03",
ooB => "Ho.107",
VAG => {
"001" => { VAG => "21.00.00.E0.8B.81.D7.F6" },
"002" => { VAG => "21.00.00.E0.8B.81.4C.F9" },
},
},
},
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.