Yes, this is why I didn't do that in the first place. Although with the data I have listed I think this would work, if I had to expand it and there weren't unique values, you're right - this wouldn't work so well. I think your 'or-ed regex' is indeed better.
For the sake of argument (I'm just playing around trying to get better a handling data in Perl and the map function), what's the best way to create a hash of arrays with this data? I can't seem to create the data structure with a map. I know this won't work as it overwrites the values on each pass:
my %data_hash = map { /^(\w\s+\d)/ => [$_] } @data2;
But, I can't seem to figure out how to create a hash of arrays with the map function. Maybe it's not possible or not the best way?
In reply to Re^5: Help understand why this grep does not work
by drmrgd
in thread Help understand why this grep does not work
by drmrgd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |