Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: parsing file/regex question

by tcf22 (Priest)
on Oct 23, 2003 at 20:49 UTC ( [id://301716]=note: print w/replies, xml ) Need Help??


in reply to parsing file/regex question

I'm assuming that the '\n' in DATA are actually new lines.

Maybe something like this is what you want:
my $re = qr/\[\s*([-a-zA-Z0-9_.*\s]+)\s*\]/; my ($last); while (<DATA>) { chomp; $_ = $last.$_ if($last); if (/$re/){ print "yep\n"; $last = ''; }elsif(substr($_, -1, 1) ne ']'){ $last = $_; }else{ $last = ''; } } __DATA__ [TEST DATA] [ TEST DATA ]

- Tom

Log In?
Username:
Password:

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

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

    No recent polls found