Assuming the web page returns 'av', 'yh' or 'gg' as values for searchengine,
you probably want to write

%se = { "av" => "AltaVista",
             "yh" => "Yahoo",
             "gg" => "Google"};

$searchengine = $q-> param('searchengine');

$search = new WWW::Search ($se{$searchengine });

I can't see any need for subroutines.

You will need to introduce a lot of checking on error conditions, and you
should probably introduce your variables with 'my' - thus:

my %se = { "av" => "AltaVista",
             "yh" => "Yahoo",
             "gg" => "Google"};

my $searchengine = $q-> param('searchengine');

my $search = new WWW::Search ($se{$searchengine });


Regards
- Roger -


----- Original Message -----
From: "Sunthari" <[EMAIL PROTECTED]>
To: "Roger C Haslock" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 3:17 PM
Subject: Re: Pls help me 2 troubleshoot


> > When you write
> >
> >
> >      $searchengine = $q->
> > param("$se{searchengine}");
> >      %se = { "av" => "AltaVista",
> >              "yh" => "Yahoo",
> >              "gg" => "Google"};
> >
> >
> > ... why do you define %se after you have used it,
> > instead of before? Why do
> > you redefine it on every call to the subroutine? Why
> Meaning I should define it before going to the
> subroutine itself ? I really dunno this.
>
> > do you call for
> > $se{searchengine}, when you have only defined
> > $se{av}, $se{yh} and $se{gg}?
> > Why do you call the subroutine only once?
>
> Well, I'm calling $se{searchengine} where
> 'searchengine' is the input taken from the user in
> webpage. User choose the search engine from the
> dropdown list.Options are Yahoo with value 'yh',
> AltaVista 'av' and Google 'gg'.
>
> > Why do you call the subroutine only once?
> Do I have to call it many times in a loop. Once user
> goes back to search, it a brand new search, right?
>
> Correct me if I 'm wrong but basically I want to read
> the input from the dropdown list and process the
> search.
>
> Thank again for your attention.Pls correct me.
>
> Rgds,
> > - Roger -
> >
> > ----- Original Message -----
> > From: "Sunthari" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, September 19, 2001 10:41 AM
> > Subject: Pls help me 2 troubleshoot
> >
> >
> > > Dear List,
> > >
> > > I'm quite a beginner to Perl (it's going to be
> > almost
> > > 2 mths).I've written the following codes and I
> > can't
> > > seem to get the correct output where user's can
> > choose
> > > their search engine for search. Pls correct me
> > since
> > > I'm really lost.
> > >
> > > Secondly, I want to use the HTML::TreeBuilder to
> > read
> > > the search results and pick up the lines with the
> > > search terms. How should I go abt it? Care to
> > share
> > > some info.
> > >
> > > Should I put the search results from e.g <body>
> > till
> > > </body> into HTML::TreeBuilder and do a match to
> > pick
> > > the lines?  Any suggestions/comments to this?
> > >
> > > Thanks in advance. Hope to hear a.s.a.p
> > >
> > > Rgds,
> > >
> > >
> > >
> > >
> >
> >
> >
> --------------------------------------------------------------------------
--
> > ----
> >
> >
> > > --
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to