Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
You could read your data into a hash table to make things a little easier on yourself, I think:

use warnings; use strict; use Data::Dumper; my @accounts = ("A x1 B y1 C z1 D v1 E w1 F", "A x2 B y2 C zzz2 D v2 E w2 F", "A x3 B y3 C z3 D v3 E w3 F", "A x4 B y4 C z4 D v4 E wwww4 F", "A x5 B y5 C z5 D v5 E w5 F", "A x6 B y6 C z6 D v6 E F"); my %fields = map { $_ => 1 } qw/A B C D E F/; my $cur_field; my %hash; foreach ( @accounts ) { foreach ( split ) { $cur_field = $_ if exists $fields{$_}; push @{$hash{$cur_field}}, $_ if $_ ne $cur_field; } } print Dumper \%hash; __END__ $VAR1 = { 'A' => [ 'x1', 'x2', 'x3', 'x4', 'x5', 'x6' ], 'B' => [ 'y1', 'y2', 'y3', 'y4', 'y5', 'y6' ], 'C' => [ 'z1', 'zzz2', 'z3', 'z4', 'z5', 'z6' ], 'D' => [ 'v1', 'v2', 'v3', 'v4', 'v5', 'v6' ], 'E' => [ 'w1', 'w2', 'w3', 'wwww4', 'w5' ] };

In reply to Re: Array in Array by kesterkester
in thread Array in Array by nylon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found