use warnings; use strict; use Text::Textile; my $textile = new Text::Textile; # to be used as a parameter my $base_url = 'http://localhost:3000'; # This is my source text my $source = '==|item|12=='; # define a hash of filters, # here we just have one $textile->filters( { item => sub { my ( $text, $r_param_list ) = (@_); my $url = $param->[0]; # $text contains the string between the last # '|' and the '==', here I expect a number $text =~ s/(\d+)/$url\/item\/view\/$1/; return $text; } } ); # Set the base URL as parameter (localhost for test) $textile->filter_param( [ $base_url ] ); # generate the result $dest = $textile->process($source); # $dest is the result