Matt,
I rewrote this with a different data structure, this is just a simple array of lines (an Array of references to lines).
Study the info you have been given.
What you want is relatively complicated to do. But I figure that you are motivated enough to get it done.

This code dumps the basic data in a 1st report.
The 2nd report shows the the folks who own a file and the other guys who want it. The report specifically excludes those who own it and want it themselves.

So the data structure is easier to understand, but the price is that it is a bit more convoluted to fiddle with.

I'm sure that the other kind Monks and I will be willing to help as you have other questions.

#!/usr/bin/perl use strict; use warnings; use Data::Dump qw(pp); #Data::Dumper is also great! $|=1; #turn off STDOUT buffering my @records; my $OwnerOrWaiting=""; while (<DATA>) { next if /^\s*$/; # skip whitespace lines s/\s+$//; # delete all trailing whitespace # this does a chomp() and a bit more.. if (/^FILENAME/) # FILENAME line defines what col #4 means { $OwnerOrWaiting = (split)[3]; } if (m/^\//) # A data line starts with '/' # I don't like "leaning toothpick" but # ok if your text editor displays wrong # colors with the other syntax - no biggie { push @records, "$OwnerOrWaiting $_"; #add status to line } } sub get_fields { my $line = shift; my %fields; @fields{qw(OWNER-WAIT FILENAME RECORD_ID M USER UNBR UNO TTY TIME D +ATE)} = split(' ', $line, 10); return %fields; } print "Dumping raw records....\n"; foreach my $line (@records) { my ($colnumber1, @rest) = split(' ',$line); printf "%-8s @rest\n", $colnumber1; } # lets print lines where we have an OWNER and at least one # other person WAITING who is not the OWNER print "\n\n"; my $current_owner=""; my $first_record=0; my @lines_in_record=(); my %temp; foreach my $line (@records) { %temp = get_fields($line); #make hash of field names if ( $temp{'OWNER-WAIT'} eq 'OWNER') # OWNER LINE { process_owner_record(); } else # WAITING LINE { push @lines_in_record, $line; } } process_owner_record(); sub process_owner_record { if (!$current_owner) { $current_owner = $temp{USER}; return; } my $new_owner = $temp{'USER'}; foreach (@lines_in_record) { my %this_record= get_fields($_); print "owner=$current_owner $_\n" if $current_owner ne $this_record{USER}; } @lines_in_record = (); $current_owner = $new_owner; } =prints Dumping raw records.... OWNER /prod-data/J 00151120273 X jmorg 3584038 247 ts/49 13:38:12 J +ul 20 WAITING /prod-data/J 00151120273 X jmorg 2015244 134 s/109 13:48:32 J +ul 20 WAITING /prod-data/J 00151120273 X gdavi 1359996 62 ts/20 13:54:22 Ju +l 20 OWNER /prod-data/J 001!L!311895 X jmorg 2015244 134 s/109 13:48:32 +Jul 20 WAITING /prod-data/J 001!L!311895 X jmorg 5713932 191 ts/46 14:01:42 +Jul 20 OWNER /prod-datahi 001!10274882 X rfuse 3354796 61 ts/43 13:39:02 J +ul 20 WAITING /prod-datahi 001!10274882 X jmorg 3584038 247 ts/49 13:39:22 +Jul 20 owner=jmorg WAITING /prod-data/J 00151120273 X gdavi 1359996 62 + ts/20 13:54:22 Jul 20 owner=rfuse WAITING /prod-datahi 001!10274882 X jmorg 3584038 24 +7 ts/49 13:39:22 Jul 20 =cut
=data_segment __DATA__ UniData Release 7.2 Build: (3786) (c) Copyright Rocket Software, Inc. 1988-2009. All rights reserved. Current UniData home is /usr/udthome/. Current working directory is /usr/local/rfs/udt. :TERM ,0 :UDT.OPTIONS 20 ON :LOGTO /ud/JWP :LIST.QUEUE FILENAME RECORD_ID M OWNER UNBR UNO TTY TIME DA +TE /prod-data/J 00151120273 X jmorg 3584038 247 ts/49 13:38:12 Ju +l 20 ---------------------------------------------------------------------- +---- FILENAME RECORD_ID M WAITING UNBR UNO TTY TIME DA +TE /prod-data/J 00151120273 X jmorg 2015244 134 s/109 13:48:32 Ju +l 20 /prod-data/J 00151120273 X gdavi 1359996 62 ts/20 13:54:22 Ju +l 20 + FILENAME RECORD_ID M OWNER UNBR UNO TTY TIME DA +TE /prod-data/J 001!L!311895 X jmorg 2015244 134 s/109 13:48:32 Ju +l 20 ---------------------------------------------------------------------- +---- FILENAME RECORD_ID M WAITING UNBR UNO TTY TIME DA +TE /prod-data/J 001!L!311895 X jmorg 5713932 191 ts/46 14:01:42 Ju +l 20 + FILENAME RECORD_ID M OWNER UNBR UNO TTY TIME DA +TE /prod-datahi 001!10274882 X rfuse 3354796 61 ts/43 13:39:02 Ju +l 20 ---------------------------------------------------------------------- +---- FILENAME RECORD_ID M WAITING UNBR UNO TTY TIME DA +TE /prod-datahi 001!10274882 X jmorg 3584038 247 ts/49 13:39:22 Ju +l 20 =cut

In reply to Re^5: How to reference to array keys? by Marshall
in thread How to reference to array keys? by mmartin

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.