Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Question regarding perl subroutine

by davies (Vicar)
on Jul 15, 2012 at 21:28 UTC ( #981932=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Question regarding perl subroutine
in thread Question regarding perl subroutine

No, that syntax cannot be right. Looking at the code you posted originally, I see:

my $ua= new LWP::UserAgent; #my $ua->agent("Mozilla/5.0"); my $ua->agent("");

You seem to be trying to use strict;, which is good (see my home node), but without understanding what it does. PerlIntro (http://perldoc.perl.org/perlintro.html#Variable-scoping) has a section on variable scoping that it might help you to understand. my creates a new instance of a variable. You may have seen examples of messages telling you that a declaration masks a previous declaration. This is telling you that you have re-initialised a variable name, which is unlikely to be what you want. I think what you want is something like:

my $ua= new LWP::UserAgent; $ua->agent("Mozilla/5.0");

but as I don't even know what LWP is, this is a pretty wild guess. http://search.cpan.org/~gaas/libwww-perl-6.04/lib/LWP/UserAgent.pm might be another good read.

Regards,

John Davies


Comment on Re^3: Question regarding perl subroutine
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-07-07 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls