Re: regex quickie

2007-04-26 Thread Andy Armstrong
On 26 Apr 2007, at 20:04, John ORourke wrote: Come on people, someone's gotta do this for a laugh... &{"do_".lc(($r->uri()=~/(\w+)\.com\//i))}(); sub AUTOLOAD { return undef; } sub do_google { } sub do_yahoo { } Nice :) -- Andy Armstrong, hexten.net

Re: regex quickie

2007-04-26 Thread John ORourke
Come on people, someone's gotta do this for a laugh... &{"do_".lc(($r->uri()=~/(\w+)\.com\//i))}(); sub AUTOLOAD { return undef; } sub do_google { } sub do_yahoo { } Yeah so I'm bored and ready for home... John

RE: regex quickie

2007-04-26 Thread sean
Martin, I recommend you keep the regex more detailed so you don't match on, for instance, 'yahoo.com?q=google' and so on. my $string = 'google.com?q=yahoo+ask.com+msn'; my $searchfuncs = {google => sub { ... }, yahoo => sub { ... }, ask => sub { ... },

Re: regex quickie

2007-04-26 Thread Jonathan Vanasco
On Apr 26, 2007, at 1:47 PM, Andy Armstrong wrote: Yeah, but that only works if all the sites use q= to prefix the query - and have to maintain the site names in two places - once in the RE and once in the despatch table. It'd be better to parse the query parameters into a hash and pass

Re: regex quickie

2007-04-26 Thread Andy Armstrong
On 26 Apr 2007, at 18:32, Jonathan Vanasco wrote: i'd keep the dispatch essentially the same, but change the regex to something more like this: my %despatch = ( 'yahoo' => sub { print "\n Yahoo! $_[0]\n"; }, 'google' => sub { print "\n Google! $_[0]\n"; },

Re: regex quickie

2007-04-26 Thread Jonathan Vanasco
On Apr 26, 2007, at 9:15 AM, Andy Armstrong wrote: my %despatch = ( 'yahoo' => sub { print "Yahoo!\n"; }, 'google' => sub { print "Google!\n"; }, ); my $match = join('|', map {quotemeta} keys %despatch); my $re = qr/($match)/i; # or whatever print "Us

Re: regex quickie

2007-04-26 Thread Andy Armstrong
On 26 Apr 2007, at 14:15, Andy Armstrong wrote: my %despatch = ( 'yahoo' => sub { print "Yahoo!\n"; }, 'google' => sub { print "Google!\n"; }, ); my $match = join('|', map {quotemeta} keys %despatch); my $re = qr/($match)/i; # or whatever print "Using

Re: regex quickie

2007-04-26 Thread Andy Armstrong
On 26 Apr 2007, at 14:03, Clinton Gormley wrote: > > perldoc perlre [look for Backtracking] > > this doesn't require backtracking to work > > just do my ($match) = ($string =~ /(google|yahoo)/i) my %despatch = ( 'yahoo' => sub { print "Yahoo!\n"; }, 'google' => sub { print "G

RE: regex quickie

2007-04-26 Thread Clinton Gormley
> -Original Message- > From: Martin Moss [mailto:[EMAIL PROTECTED] > What I would like to do is test if $string contains one of the patterns > in the pattern match and then carry out a function based upon which > pattern is matched... > Any ideas? > > > perldoc perlre [look for Backtrac

RE: regex quickie

2007-04-26 Thread John Saylor
hi -Original Message- From: Martin Moss [mailto:[EMAIL PROTECTED] What I would like to do is test if $string contains one of the patterns in the pattern match and then carry out a function based upon which pattern is matched... Any ideas? perldoc perlre [look for Backtracking]

Re: regex quickie

2007-04-26 Thread Martin Moss
h seems this worked today.. Server restart musta failed when it didn't seem to work.. if ($string =~ /($pattern_match)/i) --- Martin Moss <[EMAIL PROTECTED]> wrote: > > I'm looking for a regex which will help me do this.. > > $string = 'google.com/?q=test'; > > $pattern_match = 'google|y