in reply to Print Match name for certain rows

try this and let me know

#i just considered this is input file partnm_1 fdfg prlot dfg test line prwafer df prbin dsdg sspec dgdfg fab dfgdfgg partnm_2 sdgdf sspec dfgdg fab dfgdf partnm_3 dfsd sould not print dont prnt this is wrong

this is the perl part..let mw know if its not working

open($in,"file.txt") || die "file cannot be opened..$!"; @arr =<$in>; if(@arr1=grep/(partnm_1|prlot|prwafer|prbin|sspec|fab|partnm_2|sspec|f +ab|partnm_3)/,@arr){ print "@arr1"; }

Replies are listed 'Best First'.
Re^2: Print Match name for certain rows
by littlemonk (Sexton) on Jan 07, 2014 at 12:29 UTC
    open($in,"file.txt") || die "file cannot be opened..$!"; @arr =<$in>; if(@arr1=grep/(partnm_1|prlot|prwafer|prbin|sspec|fab|partnm_2|sspec|f +ab|partnm_3)/,@arr){ print "@arr1"; } foreach $line(@arr1){ @data =split/\s/,$line; push(@required,$data[0]); } print "@required";