On 7/16/07, yitzle <[EMAIL PROTECTED]> wrote:
Call me crazy, but...
My code now reads:
my $limit;
if ( $params =~ /[&^]limit=([0-9]{1,3})$/ ){
$limit = $1;
}
print $limit;
it now matches &limit=3$ but not ^limit=3$
Okay, you're crazy. You haven't put any data into $params, at least in
the code you're posting. More to the point, you speak falsely: Your
pattern doesn't match either of the given strings:
for my $param (qw/ ^limit=3$ &limit=3$ /) {
print "The string is '$param'.\n";
if ($param =~ /[&^]limit=([0-9]{1,3})$/ ) {
print "It matches, and \$1 is '$1'.\n";
} else {
print "No match.\n";
}
}
when the RegEx was /^limit=([0-9]{1,3})$/ it matched ^limit=3$ fine
Really? I haven't seen the code that can back up that dubious claim.
Were you using some other language than Perl?
Do you need to backslash the $ in the pattern, so that it won't mean
end-of-string? Does your data actually contain a literal dollar sign?
Don't you want to use a module to extract these CGI parameters instead
of (mis)extracting them manually?
Good luck with it!
--Tom Phoenix
Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/