in reply to Re: Perl:Use of array elements in pattern matching
in thread Perl:Use of array elements in pattern matching
Below is snippet what I have tried so far
# this is called in foreach loop and stores returns the file in array for elem and item.
my $ref_to_elem_entries = myfunction($itend_file);# This is the pattern which I look for in elem.txt if @myarr = "ELEM-3"
my @intend_elem = (win,won,wion,wiin,woon,wiioon); foreach my $itend_elem (@intend_elem) { if ($ask =~ /^SA/ && (@myarr ==1 && $myarr[0] eq 'ELEM-3')) {push @m_ref_to_elem_entries, grep(/^reg\b/,@$ref_to_elem_entries) } else {@m_ref_to_elem_entries = @$ref_to_elem_entries} }With above piece of code If condition gives me only lines for ELEM-3 and lines which has pattern stored in @intend_elem.
Else condition gives me all lines for Item & Elem files.
So far - if @myarr contains only ELEM-3 I have my result else I have results for all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl:Use of array elements in pattern matching
by Anonymous Monk on Aug 29, 2016 at 07:13 UTC |