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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |