Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Uninitialized value error

by Kanishka (Beadle)
on Aug 18, 2004 at 00:09 UTC ( [id://383851]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

Kanishka has asked for the wisdom of the Perl Monks concerning the following question:

this is the code i wrote to fetch some website. Although theres nothing wrong with the code it gives an error "Use of uninitialized value in print at Perl-1.pl line 25, <MANFWORKFILE> li ne 298." this is the code.... where have i gone wrong?
#!/usr/bin/perl -w use strict; use LWP::Simple; my @manfCode; my @next_lines; my $manf; my $counter = 0; open (MANFWORKFILE, 'C:\MyWork\OptionsDB\Belkin\Wizards\PdaConfig\manf_junk.txt'); while ( +defined($_ = <MANFWORKFILE>)){ if (/PDAConfigListModels\.asp/){ @manfCode = split(/manufacturerID\=/, $_); $manfCode[1] =~ s/\ +"\>//g; push @next_lines, scalar(<MANFWORKFILE>) if /PDAConfigListMode +ls\.asp/; $next_lines[$counter] =~ s/^[\s]+//; print $manfCode[1].$next_lines[$counter]; $manfCode[1] =~ s/\s+//; $counter ++; my $response = get("http://web.belkin.com/config/pda/PDAConfigListModels.asp? +sid=167240621&manufacturerID=$manfCode[1]"); open (INDEXFILE, '>C:\MyWork\OptionsDB\Belkin\Wizards\PdaConfig\model_junk.txt' +) or die ("Can't open out File: $!\n"); print INDEXFILE $response; clos +e INDEXFILE; } } close MANFWORKFILE;

20040818 Edit by ysth: change title from cookie ERROR?????

Replies are listed 'Best First'.
Re: Uninitialized value error
by Kanishka (Beadle) on Aug 18, 2004 at 00:26 UTC
    by the way the $manfCode[1] will get the values 121 101 104 100 102 105 consecutively.......!
Re: Uninitialized value error
by antirice (Priest) on Aug 18, 2004 at 00:38 UTC

    See the sid=167240621 part of the uri? That's your session id. That session has unfortunately expired. Oddly enough, the server gives you a 500 Internal Error response when you try to get to a page with an expired session. Since it gets a 500 response, get returns undef. Since you assign the response to $response and you later print $reponse, you get the warning. Figure out a way to get a new session and it should work as expected.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Uninitialized value error
by cLive ;-) (Prior) on Aug 18, 2004 at 14:14 UTC

    Definitely always check whether your get succeeds.

    my $response = get("http://web.belkin.com/config/pda/PDAConfigListMode +ls.asp?sid=167240621&manufacturerID=$ +manfCode[1]") || die "Couldn't retrieve web page!";

    cLive ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://383851]
Approved by ybiC
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.