in reply to Re^2: File manipulation only works when I split it into two files.
in thread File manipulation only works when I split it into two files.

Doing it in one loop:

#!/usr/bin/perl -w use strict; die "Usage: ", $0 =~ /([^\/]+)$/, " <filename>\n" unless @ARGV; $^I = ''; # We're really brave - no backup file! + while (<>){ next unless /./; # Skip empty lines tr/A-Z/a-z/; # Lowercase the lot s#^(?!http://)#http://#; # Prefix 'http://' if one is missing print; }

If 'petpages' contains the following:

foobar.com http://foo.int fOoBaR.nEt FoObAr.OrG

then running the above script with 'petpages' as an argument results in the content being changed to this:

http://foobar.com http://foo.int http://foobar.net http://foobar.org

Update: Clarified phrasing a bit.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf