Ok let me try to understand the question.

You have a form (on an HTML page or inside an application, command line or
graphics?), this form contains a textarea that should not allow users to
freely enter text but the input should be scanned for "bad" characters, if
those are found the user should recieve a warning.

Regardless of the format the backend handling will be the same because you
have to assume a user will find a way to work around any frontend
limitations you impose and send the "bad" characters directly to your
backend application.

So lets see what we can do with characters:
/
%
$
###
space

use strict;
use warnings;

use Data::Dumper;
print Dumper check_input( '/' );
print Dumper check_input( '%' );
print Dumper check_input( '$' );
print Dumper check_input( '##' );
print Dumper check_input( ' ' );
print Dumper check_input( 'abcdefghijklmnopqrstuvwxyz' );
print Dumper check_input( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' );
print Dumper check_input( '1234567890' );
print Dumper check_input( '!@^&*()_+-=' );
print Dumper check_input( 'a A' );

sub check_input {
 my $input = shift; # Take the input from @_
 return 1 unless ( $input =~ /\/|%|\$|\#\#|\s/g ); # Return 1 if the input
is free of the "bad" characters
 return 0; # Return 0 the input contained a "Bad" character
}

I think that should do the trick... but as Rob D. said your question is not
very clear so it might not be what you are looking for at all.

Regards,

Rob


On Thu, May 5, 2011 at 12:28 PM, Rob Dixon <rob.di...@gmx.com> wrote:

> On 05/05/2011 10:56, Agnello George wrote:
>
>> Hi
>>
>> I got a form with and users and insert in textarea   words like :
>>
>> /word_word2/wordword_word.txt
>> /word1_word/wordword_word2.txt
>> /word_word/word2word_word.txt
>>
>> but they should not be able to type the following  in the   text area
>>
>> /
>> %
>> $
>> ###
>> space
>>
>>
>>  unless ( $files =~ /^\s+$/ || /[\_\/\@\$\#]/) {
>>
>> print "yes ";
>>
>> }
>>
>
> I'm sorry, but I don't understand what your question is?
>
> Rob
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to