in reply to Re^2: Regex and negative file test
in thread Regex and negative file test

Yes, that was stupid of me. Thank you for pointing out my error.

Part of it is that I always use m{ ... } rather than / ... / so I have lost the habit of escaping slashes. The other part is I didn't realise that there was interpolation inside a character class so, as you point out, I failed to escape the $. Ought to do the @ as well, I suppose. Not sure about the &?

$ perl -le ' > use strict; use warnings; > print q{whatever} =~ m{[\$&<>\@/]} ? q{Yep} : q{Nope};' Nope $ perl -le ' > use strict; use warnings; > print q{v$table} =~ m{[\$&<>\@/]} ? q{Yep} : q{Nope};' Yep $ perl -le ' > use strict; use warnings; > print q{bill@bloggs.com} =~ m{[\$&<>\@/]} ? q{Yep} : q{Nope};' Yep $

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^4: Regex and negative file test
by Not_a_Number (Prior) on Dec 07, 2006 at 00:29 UTC
    Ought to do the @ as well, I suppose. Not sure about the &?

    Neither am I. We could start a long discussion here involving eg quotemeta. But I suggest that we go no further down this line, and just accept to follow Corion's excellent advice above :

    ...it is a much saner approach to only allow what is permitted instead of rejecting what you know is bad.