VinsWorldcom has asked for the wisdom of the Perl Monks concerning the following question:
I have a DNS zone file that I parsed to just the network addresses. They look like this:
1.100.10 2.100.10 3.100.10
They are in "reverse" order and I'd like to find a Perl one-liner to put them right. I've already solved my problem with a script:
use strict; use warnings; open my $fh, "<", "zones.txt"; my @lines = <$fh>; close $fh; for (@lines) { chomp $_; my @F = split /\./, $_; print join ('.', reverse @F) . "\n" }
Output would be like:
10.100.1 10.100.2 10.100.3
I'm sure there must be a one-liner with something like "perl -ape -F/./ "stuff here" zone.txt" ... but I just can't get it work. Of course I'm on Windows, so that makes the whole single quote / double quote thing a bit tricky too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: One liner help
by toolic (Bishop) on Oct 08, 2014 at 18:39 UTC | |
by VinsWorldcom (Prior) on Oct 08, 2014 at 19:55 UTC | |
by toolic (Bishop) on Oct 08, 2014 at 20:03 UTC | |
by kennethk (Abbot) on Oct 09, 2014 at 15:52 UTC | |
|
Re: One liner help
by kennethk (Abbot) on Oct 08, 2014 at 18:16 UTC | |
by VinsWorldcom (Prior) on Oct 08, 2014 at 19:53 UTC | |
by kennethk (Abbot) on Oct 08, 2014 at 23:26 UTC | |
by VinsWorldcom (Prior) on Oct 09, 2014 at 00:44 UTC |