On Wed, 04 Jun 2003 10:55:40 +1000, [EMAIL PROTECTED] (Paul Morris) wrote: >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); >}
While playing around with this, I noticed that tr won't convert to nothing. Maybe that should be a space? Or probably they meant s instead of tr? Anyways, I came up with this to do what they intended? ########################################################## #!/usr/bin/perl use strict; foreach my $inputString (<DATA>){ chomp $inputString; print "$inputString-> "; $inputString =~ s/[EMAIL PROTECTED]//g; print "$inputString-> "; if((length $inputString) == 0){print "GOOD\n"}else{print "BAD\n"} } __DATA__ !#$%^**() [EMAIL PROTECTED] #gh#$HJ99 Abc99dEgg ############################################################# As far as tr goes, substitute this line in the above script, and run it translating to // versus / /. It refuses to translate to //. $inputString =~ tr/[EMAIL PROTECTED]//; #won't work $inputString =~ tr/[EMAIL PROTECTED]/ /; #works -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]