Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regular Expression memory

by DamnDirtyApe (Curate)
on Nov 21, 2002 at 22:52 UTC ( [id://214950]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression memory

What exactly isn't working?

my $str = '<Id>3456</Id>' ; $str =~ m#(<Id>)(.*)(</Id>)# ; print "1 - $1\n2 - $2\n3 - $3\n" ; [ doug 14:49 ~ ]% perl test.pl 1 - <Id> 2 - 3456 3 - </Id>

BTW, if you're trying to parse XML, take a look at XML::Simple; it does a fine job.


_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: Regular Expression memory
by Anonymous Monk on Nov 22, 2002 at 01:18 UTC
    Thanks all replies. I figure out the problem - it's because the memory variables - $1,$2, still retains it's old value in next loop (while(<>) ) and doesn't show the correct "values"! Thanks again.

Log In?
Username:
Password:

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

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

    No recent polls found