Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Keyed list in perl

by siva kumar (Pilgrim)
on Mar 13, 2007 at 11:01 UTC ( #604502=note: print w/replies, xml ) Need Help??


in reply to Keyed list in perl

If you want to do this with regex, you can use the following code.
$line = "{chart {{1 {{title title_1} {xlable X-lab} {ylable Y-lab} {de +scription desc1} {type line} {series {{1 {{x_data {1 2 3 4 5}} {y_dat +a {20 90 60 50 30}}}}}}}}}}"; $line =~ /x_data\s+\{(.*?)\}/; print "X DATA : $1 \n"; $line =~ /y_data\s+\{(.*?)\}/; print "Y DATA : $1 \n";
UPDATE: Enclose the matching expression within if block.
if ($line =~ /x_data\s+\{(.*?)\}/) { print "X DATA : $1 \n"; } if ($line =~ /y_data\s+\{(.*?)\}/) { print "Y DATA : $1 \n"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2020-12-01 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?