Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Loading of Complex Data Structures

by davidj (Priest)
on Aug 25, 2004 at 20:29 UTC ( [id://385810]=note: print w/replies, xml ) Need Help??


in reply to Loading of Complex Data Structures

1) What exactly are you passing to insert_carrier_values? What is its structure and content?
2) From the 2 record sample you gave, what should the data structure data look like?

davidj

Replies are listed 'Best First'.
Re^2: Loading of Complex Data Structures
by vegasjoe (Sexton) on Aug 25, 2004 at 20:48 UTC
    The $array_ref is the record set. One line of the record set looks like the following:
    ...
    334 Capped 28 5034366 16777215 NULL NULL NULL
    373 Capped 28 5034366 16777215 NULL NULL NULL
    ...
    $hash_ref is an empty hash.

    It should look like:
    Key value = '55034366';
    $VAR148 = [ [ '334', 'Capped ', 28, 16777215, undef, undef ], [ '373 ', 'Capped ', 28, 16777215, undef, undef ], ]
      The following code will do what you want:
      #!/usr/bin/perl use Data::Dumper; my %HoA = (); my %hash_track = (); while(<DATA>) { chomp($_); my (@stuff) = split(" ", $_); &fill(@stuff); } print Dumper(\%HoA); sub fill() { my @a = @_; my @ar = @a[0,1,2,4,5,6,7]; my $h = $a[3]; $HoA{$h}[$hash_track{$h}] = [ @ar ]; $hash_track{$h}++; } __DATA__ 334 Capped 28 5034366 16777215 NULL NULL NULL 373 Capped 28 5034366 16777215 NULL NULL NULL
      output:
      $VAR1 = { '5034366' => [ [ '334', 'Capped', '28', '16777215', 'NULL', 'NULL', 'NULL' ], [ '373', 'Capped', '28', '16777215', 'NULL', 'NULL', 'NULL' ] ] };

      %hash_track is used to increment the first level %HoA array.

      hope this helps,

      davidj

        the above is mine. For some reason I entered it as Anonymous. Silly me

        davidj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://385810]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found