Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Side effects of an /e modifier

by Corion (Pope)
on Jan 29, 2020 at 14:13 UTC ( #11112016=note: print w/replies, xml ) Need Help??


in reply to Side effects of an /e modifier

I think the right hand side in an s///e block must be valid Perl. <td>foo($1)</td> is not valid Perl.

Quoting the HTML tags should work:

$bar =~ s#(\d{2})#"<td>".foo($1)."</td>"#mesg;

More code:

#!perl -w sub foo { "<$_[0]>" }; my $bar = '2299-33-ff'; $bar =~ s#(\d{2})#"<td>".foo($1)."</td>"#mesg; print $bar; __END__ <td><22></td><td><99></td>-<td><33></td>-ff

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2020-05-27 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?