in reply to Splits and pipes

The first argument to split is (usually, and definitely in this case) a regular expression. The pipe symbol | is a metacharacter in regexes meaning 'or' - so you've told split to split off whenever it matches a null character or a null cahracter. This happens between every character.

I think what you wanted was: ($acc_num, $ofname,$junk,$olname,$junk2) = split /\|/, $line, 5; where the backslash makes the pipe character match literally.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Replies are listed 'Best First'.
Re: Re: Splits and pipes
by cens (Novice) on Sep 06, 2003 at 21:26 UTC
    Man, I don't know how I missed that... should have known better. Thanks.

      I don't miss that one much anymore since the day I spent *hours* trying to ffigure out why split(/./, $ip_address) wouldn't work right. Complete aggravation is a good memory aid!

      --Bob Niederman, http://bob-n.com

      All code given here is UNTESTED unless otherwise stated.