Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: persistent new line

by trizen (Friar)
on Feb 15, 2012 at 17:24 UTC ( #954006=note: print w/ replies, xml ) Need Help??


in reply to persistent new line

Lines are ending with '\r\n', so the following code might help:
open FILE, '<:crlf', 'index.html'

Anyway, I would suggest the following script:

#!/usr/bin/perl use strict; use warnings; require LWP::UserAgent; my $ua = LWP::UserAgent->new( keep_alive => 1, env_proxy => 1, show_progress => 1, ); my $log_file = 'ipchanges.log'; open my $data_fh, '>>', $log_file or die "Unable to append to $log_fil +e: $!"; my $old_fh = select($data_fh); ++$|; select $old_fh; my $old_ip = ''; # your current ip while (1) { my $ip = ''; if ($ua->get('http://whatsmyip.net')->content =~ m{^<title>What's +My IP - Your IP is: ([\d.]+)}mi) { $ip = $1; printf {$data_fh} "***%s***@***%s***%s***\n", scalar localtime +(time), $ip, $ip eq $old_ip ? 'SAME' : 'CHANGED'; } $old_ip = $ip; sleep 60; }


Comment on Re: persistent new line
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-08-22 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls