Greetings respected Monks, I have a formatted file from an awk script that parsed multiple password files. The single file looks like this and I am trying to decide on what data structure to use:
/var/tmp/passwd.hostname1.platform nguyenhe 1929 20 Henry Nguyen,555-555-555 bjose 1990 20 Bobby Jose,x3338 .... .... .... /var/tmp/passwd.hostname2.platform vjain 2098 20 Vineet Kumar Jain, offshore llai 2122 20 Levius Lai bjose 1995 20 Bobby Jose,x3338 ... ... ...
to acheive my goal which is to find un-alike uids so in the above file I would print out bjose and his respected 4 fields. I was thinking of multiple hashes with multiple keys. My keys would be hostname.platform and the values would be the fields above name,uid,gid,gecos because I need to identify on what host each user-id with un-alike uid lives. Here is my code thus far, thank you!
use strict; use warnings; use diagnostics; my $awksh = qq(/home/awk_parse_passwd.ksh); my $log = qq(/tmp/uid_ck.log); my ($k,$v,$element,$line) = 0; my (@keys,@values,@glob) = (); my (%hosts,%mcg_hosts) = (); open (LOG, ">>$log") or warn "file: '$log' did not open $!"; open (AWKSH, "$awksh -|") or die "unable to spawn '$awksh' $!"; { local $/ = 'undef'; foreach $line (<AWKSH>) { (@glob) = glob("/home/passwd.*"); } } foreach $element (@glob) { ($keys[$k++]) = $element =~ m|\.(\w+\.\w+)\z|ig; }

In reply to trying to decide best data structure for problem at hand. by mikejones

Title:
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, details, 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, summary, 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.