On Sun, 24 Mar 2013 11:48:28 -0700
Angela Barone <ang...@italian-getaways.com> wrote:

> Hello,
> 
>       I'm trying to do the following, but I'm not having much luck.
> 
> ------------
> use strict;
> use warnings;
> use 5.010;
> use CGI qw(param);
> 
> my %q;
> my $referrer =
> 'http://www.bing.com/search?q=stainless+wire+rope&t=hhhh';
> 
> my $q = CGI->new($referrer);
> say '$q = '. $q->param('q');  # 'q' is empty
> ------------
> 
>       How can I get the 'q' parameter from $referrer?  In case it
> matters, this variable is coming from a db.

URI and URI::QueryParam will do exactly what you need:

  use URI;
  use URI::QueryParam;

  my $uri = URI->new($referrer);
  my $q = $uri->query_param('q');




-- 
David Precious ("bigpresh") <dav...@preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github



-- 
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