Bill Stephenson <mailto:[EMAIL PROTECTED]> wrote:

: I was playing around with it and found when I enter a "*" character
: it matches all records. That's kind of a cool feature for the users
: of this script. Are there any other special characters that will
: affect the results?

    Yes. Many many. What you are matching above is a null string.
It is not a good practice. You'll get a warning if you turn on
warnings (which *is* a good thing). If the regex engine did not
specifically check for this condition the expression would create
an infinite loop. Run this script.


#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

my @matches = grep /^*/i, qw(foo bar baz), '';

print scalar @matches;

__END__



    It is usually better to eliminate as many special characters
in a search pattern as possible. Not doing so a is big security
risk. The 'quotemeta' function and the \Q operator are meant for
this purpose. Also check out the references to tainted data in
perlsec and in perlfaq7.

    You're right, '*' is a handy way to match all the records in
your case. Just be aware of the pitfalls involved in relying on
special characters to do the work. There are many many people
out there who can wreak havoc on your server if you allow it.
Beware.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to