I think the above code has one problem in that it won't report two matches on the same line. You might prefer:

for my $column ( unpack("a40a40", $_) ) { if( $code eq soundex( (split(/,/, $column))[0] ) ) { @name_list = unpack("a18a5a7", $column); $seen{$name}++; if(++$cntr == 1) { printf("\n %-24s %-9s %-5s\n ", "Last, First M", "Ext", "Rm#"); print "=" x 40, "\n"; } printf("%-25s %-8d %-5s\n", @name_list); } }

Note also that defined @name_list is not a good idea. It might work in this specific example with your version of perl, but using defined on aggregate types (arrays and hashes) is documented as not a good idea. If you don't use my code above, change the if(defined(@name_list)) to if(0 < @name_list) or just if(@named_list)

        - tye (but my friends call me "Tye")

In reply to RE: Re: Need help with regex by tye
in thread Need help with regex by BastardOperator

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.