You can also use split to achieve the same, so instead of,$ cat replica my @dialers; while (<DATA>) { chomp; push @dialers, $1 if /replica\s+"([^"]+)/; } print $_, "\n" for @dialers; __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" $ perl replica ml_v_dialer pu_v_dialer rd_v_dialer v_dialer_drcalvin
you can write,push @dialers, $1 if /replica\s+"([^"]+)/;
(my $dialer = (split)[3]) =~ s/"//g; push @dialers, $dialer;
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
In reply to Re: how to parse to get only the replica names in an array
by naikonta
in thread how to parse to get only the replica names in an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |