SavannahLion has asked for the wisdom of the Perl Monks concerning the following question:
I have the following two code blocks I'm fiddling with. First I tried the following block.
my $phrase = "This is a test, \"using quotes of 'two different' types. +\""; $phrase =~ s/[\S*\W*]//g; print $phrase;
For some reason, the regex destroys the entire line. Therefor, print just prints a blank line. So after some fiddling I came up with the following block.
my $phrase = "This is a test, \"using quotes of 'two different' types. +\""; $phrase =~ s/[^\s*\w*]//g; print $phrase;
Which does exactly what I was aiming for in the first place. It produces the following line: This is a test using quotes of two different types All quotes, periods, and everything else has been stripped.
In my llama book it states that [^\s] is the same as \S and [^\w] is the same as \W. Now, from what I understand so far, the first block of code should have worked, but it didn't.
Why is that?
Is it fair to stick a link to my site here?
Thanks for you patience.