[Linux-disciples] Including code in a Perl regex

Stephen R Laniel steve at laniels.org
Tue Oct 26 14:43:40 EDT 2004


I'm trying to write a filter that will search through text
for a shorl.com URL and expand it into its non-shorl
equivalent. I'm using the makealongerlink() function within
the Perl WWW::Shorten::Shorl module [1], so I thought I
should be able to do this:

$infile =~ s|(http://shorl\.com[^ ]+)|(?{&makealongerlink($1)})|gs;

That's not working: what I get out the other end is
something like the literal text

&makealongerlink(http://[blah])

Any idea what I'm doing wrong? I've never used the '(?{'
operator in Perl before, so I'm sure it's just some newbie
thing.

[1] -
http://shorl.com/geketebrypibry

-- 
``PS. when Johnny hit his first homer, I announced to my
  new-found pals that "that guy is soooo getting laid
  tonight..." When he hit the second, I amended "that
  guy is soooo getting laid tonight...like 5 or 6
  times." At the end of the game is was "that guy is
  soooooo getting laid tonight...like 14 or 15 times
  with 12 different women..."
 -Laura Kathryn Boyden


More information about the Linux-disciples mailing list