in reply to Out of memory

Hello wrkrbeee,

When I added use strict to your code, I got a screenful of error messages. The first,

Global symbol "$ua" requires explicit package name at ...

highlights what looks like a serious problem: namely, that the $ua accessed within sub get_http is not the lexical variable declared below the sub, but rather an unrelated package global (which is uninitialised).

Please, add:

use strict; use warnings;

to the head of your script and fix the resultant errors before proceeding.

Update: Ok, sub get_http isn’t actually called in the code shown. But when it is called, in the larger programme, you want it to work correctly, right? Why make things harder for yourself by working without a safety net?

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Out of memory
by Anonymous Monk on Jan 15, 2015 at 22:31 UTC
    Look at this
    #!/usr/bin/perl -- use strict; use warnings; use LWP::Simple qw/ $ua /; $ua->show_progress(1); $ua->get('http://example.com'); __END__ ** GET http://example.com ==> 200 OK (2s)
Re^2: Out of memory
by wrkrbeee (Scribe) on Jan 15, 2015 at 15:21 UTC
    Thank you for your help! I inherited this program, and simply attempted to modify a miniscule portion to achieve my goal. Hence, the the GLOBAL package you mentioned is foreign to me. Sounds like a utility package incorporated by the user when needed. Guess the big question is "do I need it in this instance?" Sorry for the question.

      Hello

      When Athanasius talked about "package global", he was not referring to a package called "global", but was referring to variables that are global to the current package, which in your case, is probably "main".

      Lexical variables, which are declared with my are only available to the end of enclosing scope. Examples:

      { my $i; { my $k; ...; # both $i and $k are available here } ...; # only $i is available here for my $n (0 .. 9) { ...; # $i and $m are available here } ...; # only $i is available here }