Hi all

I found this at:

http://www.suse.com/us/private/support/howto/secprog/secprog8.html

...but am having difficulty working it out, because it doesn't seem to do what I think it should (and "I" may be the problem!).

To quote:
--------------------
The best solution is to select a filter for Perl, just like for shell, which only accepts authorized characters.


unless($userinput =~ tr/[EMAIL PROTECTED]//)
{
    print "Nice try, pal!\n";
    exit(1);
}
--------------------

I know the tranliteration search string is duplicated as the replacement string, and that the tr will return the number of changes made - it's just that I can't see how, if the input string DOES contain valid characters AND invalid characters, that the 'unless' will ever be entered.

This is my implementation of the above:
---------------
use strict;
$inputString = "&[EMAIL PROTECTED]";
print $inputString;
print "\n";
unless ($inputString =~ tr/[EMAIL PROTECTED]//){
print "Gotcha!";
}
print $inputString;
---------------

Despite having NO characters replaced, the condition is not entered...

Any thoughts?

Thanks, Paul


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to