×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

New to perl, need a little help

New to perl, need a little help

New to perl, need a little help

(OP)
I am trying to make a script that will pull my external IP address, then write the IP to a file with the date after it. I seem to be missing something here as it always gives me a result of could not find the IP. Did I not initialize or use my variables properly, or am I not parsing the site properly? Any help or pointers would be appreciated. Thanks in advance

CODE --> perl

#!/usr/bin/perl -w
use strict;
use warnings;
use File::Slurp;
use LWP::Simple;
use Time::localtime;

# Location of file to write to
my $addresses = '/home/blimpton/Pro/logger/addresses.txt';

# Find out what the external IP is
my $ip = get('https://automation.whatismyip.com/n09230945.asp');
$ip = 'Could find ip address!' if !$ip;

# Current Date
my $month = localtime->mon + 1;
my $day = localtime->mday;
my $year = localtime->year + 1900;
my $current_date = "$month-$day-$year";

# Write to the file 
if ($ip = write_file($addresses, {append => 1}, $ip . ',' . $current_date . "\n")); 

RE: New to perl, need a little help

Hi

Quote (vwyodapink)

Any help or pointers would be appreciated.
Correct the URL. That one leads to HTTP error 404. Change the protocol to http:.

Feherke.
http://feherke.github.com/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close