Dear All,
I am trying to pass list of acceptable characters in a string and then warn
user about un-acceptable characters in the said string. My sample script
goes as follows
CASE 1:-
----------------------------------------------------
my $filebuf = "ABCD123{}\[\]`";
if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/g)
#if ($filebuf =~ s/(\W)/<check>$1<\/check>/g)
{
        print $filebuf;
}
----------------------------------------------------
Now the output is
Output 1:- ABCD123<check>{</check><check>}</check>[]`

CASE 2:-
If I comment if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/gs) and
un-comment if ($filebuf =~ s/(\W)/<check>$1<\/check>/gs), then I get
following output

i.e.
----------------------------------------------------
my $filebuf = "ABCD123{}\[\]`";
#if ($filebuf =~ s/([^A-z\d])/<check>$1<\/check>/g)
if ($filebuf =~ s/(\W)/<check>$1<\/check>/g)
{
        print $filebuf;
}
----------------------------------------------------

Output 2:-
ABCD123<check>{</check><check>}</check><check>[</check><check>]</check><chec
k>`</check>

My question is
Why the CASE 1 is unable to capture characters '[' , ']' , '`' ?

Regards,
Sandeep

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to