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

Re: Re: Re: Re: Re: regex (?{CODE}) question

by elusion (Curate)
on Aug 01, 2002 at 19:59 UTC ( [id://186910]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: regex (?{CODE}) question
in thread regex (?{CODE}) question

Try using the /e modifier. What it does is make the second half of the regex executed as code. In your case you'd want something like this:
$str = "(<ref links=\" cit314-1 cit314-2 cit314-3 cit314-4 cit314-5\"/ +>)"; if( $str =~ s/<ref links="(.*?)"(.*?)\/>/ "<ref links=\"$1\"$2>" . getString($1) . "<\/ref>"/e ){ print "Match was found." . "\n"; } print $str . "\n"; sub getString($s){ my $s = shift; ...more processing of $s... return $s; }
Your $str changed from your previous posts, so I changed it back to the way it was in the other posts. Notice how I quoted the tags and concatenated them with the return value from the subroutine. I also did some extra formatting. Hope this helps.

elusion : http://matt.diephouse.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://186910]
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-04-25 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found