Hi Vinoth and Ken, Actually my requirement is there are two files
F1,F2 F1 has data NAMES ** name1 name2 ADDRESS street1 street2 PHONE ** num1 is num2 is F2 has data name1 sirname1 street1 housenumber 1 num1 is 8784794 num2 is 9888948 street2 housenumber23 name2 sirname2
so i read each line in F1 and see if its mandatory(ends with (**) then under that heading i take the values and its corressponding complete value is taken from F2 so finally what i should get is
Thanks , my code isNAMES name1 sirname1 NAMES name2 sirname2 PHONE num1 is 8784794 PHONE num2 is 9888948
#! usr/bin/perl use strict; use warnings; my $line; my $str; use diagnostics; open my $file_one,'<','F1' or die "unable to open"; while(defined($line=<$file_one>)) { chomp($line); if ($line =~m/(\*\*)/) { $str = $line ; # print " $str \n"; } else { open my $file2,'<','F2' or die "unable to open "; while(defined(my $line2=<$file2>)) { if($line2=~m/$line/) { print " line : $str line2: $line2\n"; } } close($file2); } }
its giving error
where line 21 is the pattern matching statement if($line2=~m/$line/)Invalid [] range "=-," in regex; marked by <-- HERE in m/ 144 x Lc +b (P CAL_LCBMS [CAL_LCBMS] T lcb I [ACT=-, <-- HERE NCLK=chpl::ec0+clk, FORCE_T=-, SG=chpl::ec0+sg+region1+no_l +cc+plat_flush_nto1, THOLD_B=chpl::ec0+sl_thold+ab st+region1+no_lcc, MPW1_B=-, MPW2_B=-, DLY_LCKR=-, DLY0=chpl::ec0+time ++region1+no_lcc+slat, DLY1=chpl::ec0+time+region1 +no_lcc+slat, PW0=chpl::ec0+time+region1+no_lcc+slat, PW1=chpl::ec0+ti +me+region1+no_lcc+slat, PW2=chpl::ec0+time+region 1+no_lcc+slat] E [SG=OR(chpl::ec0+lbist_ary at ./stest line 21, <$file +2> line 1. at ./stest line 21
In reply to Re^2: Nested While loop not working
by Manisha
in thread Nested While loop not working
by Manisha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |