Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Splits and pipes

by bobn (Chaplain)
on Sep 06, 2003 at 21:23 UTC ( [id://289509]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://289509]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-29 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found