in reply to functions inside patterns
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;"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (crazyinsomniac) Re: functions inside patterns
by cheesyjames (Novice) on Dec 20, 2001 at 10:55 UTC | |
by crazyinsomniac (Prior) on Dec 20, 2001 at 11:12 UTC | |
|
Re: (crazyinsomniac) Re: functions inside patterns
by cheesyjames (Novice) on Dec 20, 2001 at 11:05 UTC |