enkibian has asked for the wisdom of the Perl Monks concerning the following question:
welcome Perl Worshippers
please tell me why I am getting new line after printing $line variable?
sorry for maybe messed code :P, asterisks and @ just to show in print what's happening, need to run in on Linux and create ipchanges.log before
#! /usr/bin/perl while (1){ unlink ("index.html"); $content = `wget -nv http://whatsmyip.net/`; open FILE,"index.html"; @content = <FILE>; close FILE; open DATA, ">>ipchanges.log"; foreach $line(@content){ if ($line =~ "<title>"){ $line =~ s/://g; $line =~ s/<title>//g; $line =~ s/<\/title>//g; $line =~ s/ //g; $line =~ s/What'sMyIP-YourIPis//g; $data = `date`; chomp $data; chomp $line; $line =~ s/\t//g; $line =~ s/\n//g; if ($line !~ $oldip) { print DATA "***$data***@***$line***CHANGED* +**\n"} else {print DATA "***$data***@***$line***SAME***\n"} $oldip = $line; } } sleep 60; close DATA; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: persistent new line
by AR (Friar) on Feb 15, 2012 at 15:46 UTC | |
by tye (Sage) on Feb 15, 2012 at 18:37 UTC | |
by enkibian (Initiate) on Feb 16, 2012 at 00:18 UTC | |
by AR (Friar) on Feb 16, 2012 at 18:29 UTC | |
|
Re: persistent new line
by VinsWorldcom (Prior) on Feb 15, 2012 at 15:50 UTC | |
|
Re: persistent new line
by trizen (Hermit) on Feb 15, 2012 at 17:24 UTC | |
|
Re: persistent new line
by enkibian (Initiate) on Feb 16, 2012 at 00:30 UTC | |
by Anonymous Monk on Feb 16, 2012 at 06:09 UTC | |
by Marshall (Canon) on Feb 16, 2012 at 23:23 UTC | |
|
Re: persistent new line
by Karkadan (Initiate) on Feb 15, 2012 at 18:57 UTC |