in reply to Using constants inside regex
</ShamelessSelfPromotion>use Filter::Interpolate; use constant TEST => 3; my $string="123456"; $string =~ s/\Q$(TEST)\E/9/; print $string, "\n"; $string =~ s/2/$(TEST)/; print $string, "\n";
It should also be pointed out that the @{[THING]} hack will work with subroutines too. It will also work in double-quoted strings and anywhere else interpolation happens.
=cut
--Brent Dax
@HPAJ=split("", "rekcaH lreP rentonA tsuJ"); print reverse @HPAJ; #sucky but who cares?
|
|---|