On Mon, 25 Oct 2004, E.Horn wrote:

> I want to get information out of this page.
> My problem is, how can i give ($eingabe) into the url?
> Because that varies the output of the xmlsource!
>
> example:
>
>   $url=.........term=gtpase...
>
> gives me the result of all gtpases...
> 
> How can I use a function or variable to make it possible to give it 
> into the stdin and that gives the content of stdin into the end of my 
> url???
> 
>   #!/usr/bin/perl -w
>   use LWP::Simple;
> 
>   $eingabe=0;
>   chomp($eingabe =<>)
> 
>   $url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi?term=$eingabe';
> 
>   $doc = get $url;
>   print $doc;

What counts as valid input? You're not doing any kind of checks here, so 
the user can upload just about anything to the site. Chances are 
excellent that this will allow Bad Things to Happen on the receiving 
end, if not on your end. Anything at all you can do to validate $eingabe 
before sending it to the nih.gov server would be worth doing. 

But that's as an aside. 

What happens when you pass the script canned values for $eingabe to use?

   #!/usr/bin/perl -w
   use LWP::Simple;

   $url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi?term=';

   $eingabe = "gtpase";
 
   $doc = get "$url$eingabe";
   print $doc;
 
That works, right?

If so, maybe the right approach is to pass the script arguments when it 
is invoked rather than pulling them in after launch on standard input. 
Take a look at a module like Getopt::Std and Getopt::Long to do this:

Getopt::Std:

   use warnings;
   use strict;
   use Getopt::Std;

   my %opts;
   getopt('a');
      # sets $opts{'a'} to whatever the user put for '-a ...'

Getopt::Long:

   use warnings;
   use strict;
   use Getopt::Long;

   my $eingabe;
   my $result = GetOptions ( "arg=s" => \$eingabe );
      # sets $eingabe to whatever the user put for '--arg=...'

I believe these modules are bundled with most versions of Perl 5.x. Look 
up the documentation in `perldoc Getopt::Std` & `perldoc Getopt::Long`.



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to