Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: how to read words in a line into separate variables

by kroach (Pilgrim)
on May 27, 2015 at 20:20 UTC ( #1128069=note: print w/replies, xml ) Need Help??


in reply to how to read words in a line into separate variables

You can use a regular expression with capture groups in list context:

my $string = q{write("thepath",8'h44,status,"info")}; my ($e, $a, $b, $c, $d) = $string =~ /\A(.+?)\("(.+?)",(.+?),(.+?),"(. ++?)"\)\Z/;

I don't know the exact format of your data, so I used non-greedy anything match (.+?). It's better to adjust the expression to the format as strictly as possible, though.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-10-26 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (250 votes). Check out past polls.

    Notices?