Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Here's another option that will generate your desired results:

use Modern::Perl; use Sort::Key::IPv4 qw(ipv4sort); my %hash; do { chomp( my ( $ip, $fld2, $fld3 ) = ( split /\t/ )[ 1 .. 3 ] ); push @{ $hash{$ip} }, "$fld2=$fld3"; } for <DATA>; print "$_|" . join( '|', @{ $hash{$_} } ) . "\n\n" for ipv4sort keys % +hash; __DATA__ 9885 Room 1105A 9885 Jack 1105A--05D 9885 org_code B703 9885 Building 1268A 114948 nasa_nets off 114948 blockSecName test name 114948 blockTechName brian test 114948 blockAdminName test admin 114949 blockSecName John G. Smooth 114949 blockTechPhone 256-555-1212 114949 blockAdminName Lucy P. Wallice 114949 blockAdminId 8878787 114949 block_name unknown 114949 blockSecId 787878 114949 blockAdminEmail 114949 blockTechName TEST LAN 114949 blockSecPhone 256-555-3232 114949 blockTechEmail 114949 blockSecEmail 114949 nasa_nets Soff

Output:|Room=1105A|Jack=1105A--05D|org_code=B703|Building=1268A|nasa_nets=off|blockSecName=test name|blockTechName=brian t +est|blockAdminName=test admin|blockSecName=John G. Smooth|blockTechPh +one=256-555-1212|blockAdminName=Lucy P. Wallice|blockAdminId=8878787| +block_name=unknown|blockSecId=787878|blockAdminEmail=lucy.p.wallice@n|blockTechName=TEST LAN|blockSecPhone=256-555-3232|blockTechEm||nasa +_nets=Soff


I've added the Sort::Key::IPv4 module to use its ipv4sort on the IP4 addresses in your data set. The advantage is an ordered list of results. Its limitation is not sorting on IP6 addresses. This IP4 sorting was easily added, and can be easily removed if not needed.

In reply to Re: split then join based on common value in field by Kenosis
in thread split then join based on common value in field by brianjb

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the pool shimmers...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (7)
    As of 2018-05-21 18:02 GMT
    Find Nodes?
      Voting Booth?