Hmmm, Are you sure? the dot "." matches everything but "\n", so it will not expand through newlines (see perlretut):
use strict; use warnings; use Data::Dumper; { local $/; my @replica = <DATA> =~ /replica\s+"(.+)"/g; print Dumper \@replica; } __DATA__ 2005-04-01 root replica "ml_v_dialer" 2004-06-22 root replica "pu_v_dialer" 2006-02-11 ccvob01 replica "rd_v_dialer" "v_dialer replica for Redmond" 2003-11-25 root replica "v_dialer_drcalvin"
Outputs:
$VAR1 = [ 'ml_v_dialer', 'pu_v_dialer', 'rd_v_dialer', 'v_dialer_drcalvin' ];
And:
use strict; use warnings; use Data::Dumper; my @replica; while (<DATA>){ next if (! /^\d+/); /replica\s+"(.+)"/; push @replica,$1; } print Dumper \@replica; __DATA__ 2005-04-01 root replica "ml_v_dialer" 2004-06-22 root replica "pu_v_dialer" 2006-02-11 ccvob01 replica "rd_v_dialer" "v_dialer replica for Redmond" 2003-11-25 root replica "v_dialer_drcalvin"
Prints the same:
$VAR1 = [ 'ml_v_dialer', 'pu_v_dialer', 'rd_v_dialer', 'v_dialer_drcalvin' ];
citromatik
In reply to Re^3: how to parse to get only the replica names in an array
by citromatik
in thread how to parse to get only the replica names in an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |