On 8/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I've had some success passing various airport codes
> to the other subroutines using functions like lwp::simple, but in this
> one it's not working.

Has anyone suggested using higher-level WWW::Mechanize instead of
low-level LWP::Simple? It's not the same as buying butter instead of
milk and a churn, but it's a step in the right direction for many
applications. (Maybe yours, maybe not.)

> use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

I hope that you comment-out or remove that line when you're done
developing your code. Otherwise, someone who discovers a flaw in your
program gets to see a helpful error message explaining what they did
wrong, and can all the more easily use that flaw to break in to your
system.

> sub FcstPress {
> my $url = 'http://68.226.77.253/text/NAM80km/[EMAIL PROTECTED]';
> #substitutes passed variable into @_ like ksfo.txt

Your e-mail application (or something along the way) seems to have
lost the indentation for your program; every line starts at the left
margin on my screen. This part is clear: The comment is a lie, since
variables don't interpolate into single-quoted strings. But even if it
used double quotes, it works only for exactly one subroutine argument,
doesn't it? There may be a better way.

  my $tla = shift @_;
  die "Unexpected tla: '$tla'" unless $tla =~ /^\w+$/; # maybe
  # Here's double-quote interpolation for you:
  my $url = "http://68.226.77.253/text/NAM80km/NAM_k$tla.txt";;

If @_ contains more than one item, your subroutine could perhaps
return a list of responses. Or it might be better to die with a
message about bad usage, depending upon your situation.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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


Reply via email to