By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,852 Members | 2,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,852 IT Pros & Developers. It's quick & easy.

Environment variable not defined

P: 7
Under AIX 5.3, I have created a script that checks URL availability with LWP::UserAgent.

Before I run the script, I must define the variable LIBPATH for my script to know where is the SSL library. Otherwise it won't be able to evaluate https URL. That is working fine...

LIBPATH='/opt/freeware/lib'

I'd like to avoid defining the variable before running the script, but when I try to define the variable at the beginning of the script, the script output says no https support (meaning that the LIBPATH variable has not been defined).

I don't know what's wrong...


Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. BEGIN { $ENV{'LIBPATH'}='/opt/freeware/lib'; }
  7. use LWP::UserAgent;
  8.  
  9. my $url;
  10. my $Firefox = "Mozilla/5.0";
  11. my $response;
  12. my $ua = LWP::UserAgent->new;
  13.  
  14. $url=$ARGV[0];
  15.  
  16. $ua->agent($Firefox);
  17.  
  18. $response = $ua->get($url);
  19.  
  20. if ( $response->is_success) {
  21.   print "SUCCESS\n";
  22.   print $response->status_line, "\n";
  23. }
  24. else
  25. { print "NOT A SUCCESS\n";
  26.   print $response->status_line, "\n";
  27. }
  28.  
Thanks for your help!
Sep 17 '08 #1
Share this Question
Share on Google+
3 Replies


eWish
Expert 100+
P: 971
Try using the lib pragma.

--Kevin
Sep 17 '08 #2

P: 7
I've tried to add:

use lib '/opt/freeware/lib';

The folder has been added to @INC, I have confirmed it by adding these lines :

foreach (@INC) {
print "$_\n";
}


Any other idea?
Sep 18 '08 #3

eWish
Expert 100+
P: 971
Not sure what's wrong. Maybe one of our experts will be able to assist further.

--Kevin
Sep 18 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.