Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Some Weird behavior with BerkeleyDB and WWW::Mechanize

by downer (Monk)
on Dec 05, 2007 at 20:39 UTC ( [id://655216]=note: print w/replies, xml ) Need Help??


in reply to Re: Some Weird behavior with BerkeleyDB and WWW::Mechanize
in thread Some Weird behavior with BerkeleyDB and WWW::Mechanize

there really isnt much else to my code:
#!/usr/bin/perl -w use strict; use BerkeleyDB; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my %pageHash; tie %pageHash, "BerkeleyDB::Btree", -Filename => 'pageContents', -Flags => DB_CREATE, or die "Cannot open file pageContents: $! $BerkeleyDB::Error\n +" ; my %hash; tie %hash, "BerkeleyDB::Btree", -Filename => 'videoDB', -Flags => DB_CREATE, or die "Cannot open file videoDB: $! $BerkeleyDB::Error\n" ; foreach my $x (keys %hash) { print "getting $x:"; my $data = $hash{$x}; my @parts = split(/\t/, $data); my $url = $parts[0]; $mech->get( "$url" ); if($mech->success()) { #$pageHash{$x} = $mech->content( format => 'text' ); print " done\n"; } else { print " failed\n"; } sleep(15); }

Replies are listed 'Best First'.
Re^3: Some Weird behavior with BerkeleyDB and WWW::Mechanize
by moritz (Cardinal) on Dec 05, 2007 at 20:50 UTC
    I tested your code (I added two URLs to the hash) and I can't reproduce your problem. Neither key nor value get modified in any strange ways.

    Maybe try to move your pageContents files and start with an empty, clean one and check if the error still occurs.

      i get the following error :  Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/vendor_perl/5.8.6/HTTP/Cookies.pm line 45. each time through the loop. I think this is happening somewhere within the WWW::Mechanize->get(), maybe this regex is modifying the regex somehow?
        I seriously doubt that.

        If you look at sub get in Mechanize.pm:

        sub get { my $self = shift; my $uri = shift; ...

        The parameter $uri is passed by value, which means it is copied.

        Even it is modified later on, you'll never see that in your script because it's just a copy that's modified.

        However the uninitialized value might be a hint. Check $url for definedness, and die if it's not, then rerun your script.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://655216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-04-23 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found