Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: persistent new line

by trizen (Hermit)
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('')->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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2016-02-14 05:06 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (457 votes), past polls