I'm with blazer on this one, I don't like all those variables names. Having to take "username" by slicing the 5th element from your array is creating depencies on the order of your data. I'd have read the data into hashes in like this.
use Data::Dumper;
my %on_prop;
my %on_user;
while (<DATA>) {
my @fields = split "\t";
my %column_data = map {$_, shift(@fields)} qw(PROP COLOUR TXTCOL U
+RL360 USER YOUR_NAME ETC);
$on_prop{$column_data{PROP}} = \%column_data;
push @{$on_user{$column_data{USER}}}, \%column_data;
}
print Dumper(\%on_prop);
print Dumper(\%on_user);
print scalar @{$on_user{'rob'}}; # prints 2 (more than one item for t
+his user)
__DATA__
123 Red blue whatever rob blah blah blah
124 Red blue whatever rob blah blah blah
125 Red blue whatever jon blah blah blah
---
my name's not Keith, and I'm not reasonable.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.