Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: split and @

by davido (Archbishop)
on Jan 07, 2013 at 18:40 UTC ( #1012089=note: print w/ replies, xml ) Need Help??


in reply to split and @

In your first test, you're splitting on 'comma', and your input string conveniently contains commas. So you get the desired behavior of @input receiving elements ab, cd, efghi, and jkl.

In your second test, you're splitting on @, which is not present in your input string at all. Thus (contrary to what your #comment says), the string isn't being split; it doesn't contain anything that matches your split pattern. Consequently, you get the undesired behavior of @input receiving a single element, "ab,cd,efghi,jkl"

If you're dealing with CSV files, or anything more complex than very simple un-quoted comma delemited text, Text::CSV will save you headaches and development time in the longrun.


Dave


Comment on Re: split and @
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2015-07-31 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls