bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
This my be slightly OT for a PM SoPW question, but ... In my HTML I allow the user to click groups of 3 consecutive letters to narrow what will be displayed in a list.
HTML: <a href="../cgi-bin/listusers.pl?alpha=ABC">ABC</a> <a href="../cgi-bin/listusers.pl?alpha=DEF">DEF</a> etc....
My Perl attempts to set up the appropriate REGEXP in a MySQL SELECT statement to return only those lastnames beginning with those letters:
my $alpha = $query->param('alpha'); $alpha =~ /(\w)(\w)(\w)/; $stmt = "SELECT * FROM teamnew ORDER BY lastname WHERE lastname REGEXP + '^$1|^$2|^$3'";
But I keep getting an error that there is a syntax error in my SELECT statement. A print Dumper for $stmt shows:
which appears fine. What am I missing? TIA."SELECT * FROM teamnew ORDER BY lastname WHERE lastname REGEXP '^A|^B| +^C'"
20050204 Edit by castaway: Changed title from 'Setting up a MySQL REGEXP in Perl'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (OT) Setting up a MySQL REGEXP in Perl
by edoc (Chaplain) on Jan 31, 2005 at 14:44 UTC | |
by bradcathey (Prior) on Jan 31, 2005 at 17:15 UTC | |
|
Re: (OT) Setting up a MySQL REGEXP in Perl
by dragonchild (Archbishop) on Jan 31, 2005 at 14:26 UTC |