[Israel.pm] Replace with Variable content

Yuval Yaari yuval at windax.com
Thu Oct 13 06:03:22 PDT 2005

ik wrote:

>I would like to do the following:
>use strict;
>my $allowedChars = "a-zA-Z\x{50D}";
>$line =~ s/[^$allowedChars]//gs;
>Now as you can see, this code will not be allowed to be used. So my
>question is how can I do something in this idea ?
I'm not sure; I'm using perl 5.8.7 and it works:
use strict;
my $allowedChars = "a-zA-Z\x{50D}";
my $line = 'a$b$c$d';
print "line 1 : $line\n";
$line =~ s/[^$allowedChars]//gs;
print "line 2 : $line\n";


line 1 : a$b$c$d
line 2 : abcd

I also tried using warnings and diagnostics and still got no error/warning.


More information about the Perl mailing list