Gurus,
I'm trying to use map--instead of a for loop--to split an array into a
hash. As you can see by the output I'm getting, it ain't workin'. Am I
doing something wrong, or am I just trying the impossible? Here's the
code, followed by what I get, followed by what I *want* to get.
TIA!
didyou expect the comments to be removed automatically? Hmm (note the
@ary/@data change)
my %hash = map { split /\s\|/ } grep { /\|/ } @data; # line 76
works:
000: Somewhere/something/thisplace/someplace/Things/here//Value
001: Somewhere/something/thisplace/someplace/Things/here//Value
Thanks Andy! The Systems Mangler strikes again!
Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150
Oh, what a tangled web do parents weave, when they think their children
are naive. -- Ogden Nash___
ActivePerl mailing list
[EMAIL PROTECTED] wrote:
didyou expect the comments to be removed automatically? Hmm (note
the @ary/@data change)
my %hash = map { split /\s\|/ } grep { /\|/ } @data; # line 76
Making sure that split can't produce more that 2 fields may be a bit
safer, just in case there is a
my %hash = map { split /\s\|/ } grep { /\|/ } @data; # line 76
Comments containing '|' will produce surprising results.
When parsing data, i would recommend not to aim for brevity,
but to aim for clarity, robustness and maintainability -
unless you are training for a code obfuscation