in reply to Regular Expression and backquoted cmds
returns...use warnings; use strict; use Data::Dumper; my @none; my %hash = map { chomp; local @_ = split; if (/\sNONE$/) { push(@none, $_[0]); (); } else { ($_[0] => $_[1]) + }; } grep /^ID\d+/, <DATA>; warn Dumper \%hash, \@none; __DATA__ Script version 1.7 12345 hashes read from 1 database 3 read, 2 found, 2 written ID123 ZZ00000077 ID456 ZZ00000012 ID124 NONE
assuming the lines of interest always comprise just 2 whitespace separated fields.:!perl test.pl $VAR1 = { 'ID456' => 'ZZ00000012', 'ID123' => 'ZZ00000077' }; $VAR2 = [ 'ID124' ];
BTW, as rovf points out, if you want STDOUT populating, you'll have to print each line as it's read from the command ...
|
|---|