Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Get unique fields from file

by choroba (Archbishop)
on Jan 06, 2022 at 12:00 UTC ( #11140218=note: print w/replies, xml ) Need Help??


in reply to Get unique fields from file

The first argument of split is a regex, not a string. "|" is an alternative of two empty strings.
my @fields = split "|", 'abc|def'; print join ', ', @fields; # a, b, c, |, d, e, f
If you want to split on the literal vertical bar, you need to backslash it.
my @fields = split /\|/, 'abc|def'; print join ', ', @fields; # abc, def
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-08-19 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?