-----Original Message-----
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 03, 2006 5:41 PM
To: 'Perl Beginners'
Subject: RE: has key/value pairs

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.

*****************************

Ok guys, yes that was just pseudo code and I was in a hurry to get it
off.
I was being lazy.  I have been around awhile, but laziness got the best
of me that time-around.
Now I understand why 

for (<FH>)
    if (/pattern/) {
        split /\=/, $_;
        $vg{$_}++
    }
}

will not work...aka I was not capturing that list.
Thank you
Derek


Derek Bellner Smith
Unix Systems Engineer
Cardinal Health Dublin, Ohio
614-757-5000 Main
614-757-8075 Direct
614-757-8120 Fax
[EMAIL PROTECTED]

Cardinal Health -- Working together. For life. (sm)
_________________________________________________

This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information. If you have received it in 
error, please notify the sender immediately and delete the original. Any other 
use of the email by you is prohibited.

Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk 
- Portuguese - Svenska: www.cardinalhealth.com/legal/email

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to