Environment variable not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbrunell
    New Member
    • Sep 2008
    • 7

    Environment variable not defined

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


    Code:
    #!/usr/bin/perl
     
    use strict;
    use warnings;
     
    BEGIN { $ENV{'LIBPATH'}='/opt/freeware/lib'; }
    use LWP::UserAgent;
     
    my $url;
    my $Firefox = "Mozilla/5.0";
    my $response;
    my $ua = LWP::UserAgent->new;
     
    $url=$ARGV[0];
     
    $ua->agent($Firefox);
     
    $response = $ua->get($url);
     
    if ( $response->is_success) {
      print "SUCCESS\n";
      print $response->status_line, "\n";
    }
    else
    { print "NOT A SUCCESS\n";
      print $response->status_line, "\n";
    }
    Thanks for your help!
    Last edited by numberwhun; Sep 17 '08, 04:57 PM. Reason: Please use code tags
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    Try using the lib pragma.

    --Kevin

    Comment

    • mbrunell
      New Member
      • Sep 2008
      • 7

      #3
      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?

      Comment

      • eWish
        Recognized Expert Contributor
        • Jul 2007
        • 973

        #4
        Not sure what's wrong. Maybe one of our experts will be able to assist further.

        --Kevin

        Comment

        Working...