Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by kroach (Pilgrim)
on May 27, 2015 at 20:20 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128069]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found