in reply to Re^2: Removing and replacing values from an array.
in thread Removing and replacing values from an array.
See -p, -i[extension], and -e commandline in perlrun for details on the command line flags. In script form, this might be implemented as (where I have now stored data rather than modifying the input file)perl -pibak -e 's/^\s.*//; s/\[\.\]/./g;' filename
or more simply#!/usr/bin/perl use warnings; use strict; my @ips; while (my $line = <STDIN>){ last if $line =~ !/\S/; $line =~ s/^\s.*//; $line =~ s/\[\.\]/./g; push @ips, $line; } my @urls; while (my $line = <STDIN>){ last if $line =~ !/\S/; $line =~ s/^\s.*//; $line =~ s/\[\.\]/./g; push @urls, $line; }
See Loop Control in perlsyn for details on last.#!/usr/bin/perl use warnings; use strict; my @ips; while (<>){ last if !/\S/; s/^\s.*//; s/\[\.\]/./g; push @ips, $_; } my @urls; while (<>){ last if !/\S/; s/^\s.*//; s/\[\.\]/./g; push @urls, $_; }
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Removing and replacing values from an array.
by Laurent_R (Canon) on Aug 18, 2014 at 17:52 UTC | |
by kennethk (Abbot) on Aug 18, 2014 at 18:34 UTC | |
by Laurent_R (Canon) on Aug 18, 2014 at 18:55 UTC | |
|
Re^4: Removing and replacing values from an array.
by douggie305 (Initiate) on Aug 18, 2014 at 17:26 UTC |