Smith, Derek wrote:
: Excellent... thank you. Before sending the email question, I
: was trying to use split to get rid of that and could not get
: it to work as I was using
: <code>
:
: For (<FH>)
: If (/pattern/) {
: split /\=/ ,$_ /;
: $vg{$_}++
: }
: }
: </code>
:
: Why didn't this work?
Because it is wrong on so many levels. Seriously, assuming
the capitalization of "for" and "if" are typos, you can't just
add a slash "/" wherever you want to and expect perl to know
why. Assuming that trailing slash is also a typo, And you
really meant this ...
for (<FH>)
if (/pattern/) {
split /\=/, $_;
$vg{$_}++
}
}
... then there are still problems. First split() returns
a list of values, but you are not capturing that list. I think
that split() defaults to placing its values in @_, but you are
not accessing that here and it is deprecated.
All the work is being done in "$vg{$_}++" which ignores
the split() and increments the value associated with the key
in $_. That one of those key/value pairs happens to be correct
is just coincidence.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>