The other thing I think you might be thinking (dang that sounds stupid) is something along the lines of m/\d$pattern\b\l\a\h &what('what')/ where you want &what('what') to be expanded, in which case the only thing I can think of is for you to either store the value of &what in a variable.#!/usr/bin/perl -lw use strict; # here is one thing you might want sub what { my $what = shift; return ($what - 5); } my $string = 'a and a b and a 5 and a 6 and a 8 an what?'; print $string; $string =~ s/(\d)/&what($1)/ge;
update: well you could always use eval, but I find that is in poor taste (I think it is a piss poor choice in design, when one must resort to "passing" functions via STDIN).
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"
In reply to (crazyinsomniac) Re: functions inside patterns
by crazyinsomniac
in thread functions inside patterns
by cheesyjames
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |