Re: [htmltmpl] Fun with Filters.
Brought to you by:
samtregar
From: Chisel W. <ch...@he...> - 2003-08-13 16:23:56
|
On Wed, Aug 13, 2003 at 09:31:54AM -0500, Jeff Pelkey wrote: > YA?: What does the "$$" mean in $$test_ref. $text_ref is a reference to a scalar, so to get the text itself you need to dereference it. It's proably easier to understand if you think of it as ${$text_ref}. It's the same as you'd do with hash an array references. > my $filter = sub { > my $text_ref = shift; > $text_ref =~ s/!!!ZAP_(.*?)!!!/<TMPL_$1>/g; > $$text_ref; > ## Also Tried Adding "return $text_ref;" - No Difference. > }; I think that here you want: $$text_ref =~ s/!!!ZAP_(.*?)!!!/<TMPL_$1>/g; (as per the example in the H::T documentation) > sub test_function { > ##my $str1 = shift; > my ($str1, $str2) = @_; > my $strTest = qq~Hi this is some text: '$str1-$str2'.~; > return $strTest; > } Do you get other arguments passed into a filter? I can't say I've ever tried, but wouldn't expect more than $text_ref. However, you want to use $$str1 to get the actual text held in str1, $str1 is a reference to a scalar. I think. Chisel -- e: ch...@he... | I may contradict myself, but at least w: http://www.herlpacker.co.uk/ | I don't contradict myself. gpg: D167E7FE | |