perl newbie

Posted on 2012-09-18
Last Modified: 2012-09-19
hi experts,

i am new to perl and very lazy.

i am trying to run the following program so that it prints the web page from for a start.
further i want to grep for string "Your IP Address Is:" and print my WAN IP to std out.

However my very first challenge is that program fails with following error:
"Use of uninitialized value in print at ./ line 11."

can you kind souls, please
- enlighten me how to fix the above error
- add additional plumbing to my scriptlet so that, it prints only the IP retrieved from this page.
#!/usr/bin/perl -w

use LWP::Simple;
use strict;

my $url = "";

my $content = get($url);
print $content;

i will pray for a 10 fold increase in yr kindness and your intellect. :)
Thanks Experts
Question by:sherrysidhu
    LVL 76

    Assisted Solution

    You are using -w and strict;

    Each means that you  must pre-define or pre-declare every variable you will be using.
    my $content, $url;

    Not sure which line is at fault try
    perl -c
    It should pont to the line at fault.
    The get($url)

    The difficulty is the error might be that get($url) does not get a response such that $content is null which you then try to print.
    LVL 26

    Accepted Solution


    Your problem is that will only accept requests from Browsers, or a script that has an appropriate User Agent set in the GET message header. If you try from a script, without spoofing, they'll bounce the request e.g.

    perl -MLWP::Simple -e 'getprint ""'
    403 Forbidden <URL:>

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    A short article about problems I had with the new location API and permissions in Marshmallow
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now