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

NAMES name1 sirname1 NAMES name2 sirname2 PHONE num1 is 8784794 PHONE num2 is 9888948
Thanks , my code is
#! 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

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
where line 21 is the pattern matching statement if($line2=~m/$line/)


In reply to Re^2: Nested While loop not working by Manisha
in thread Nested While loop not working by Manisha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.