Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Get unique fields from file

by choroba (Cardinal)
on Jan 06, 2022 at 12:00 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-26 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found