Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I am very new in perl. One of the file has some junk and starts with
define 1
.
.
.
and ends with suppose
America 331
I need to get rid of those junk and and my array(1) should start from this line define 1
which has to merge with the first array of another file. And I want to grab suppose
define 9 which has to merge with array 9 of other file. Any suggestion?Thank you very much.

Replies are listed 'Best First'.
Re: Mactching arrays and reg. exp.
by eak (Monk) on Aug 03, 2000 at 19:04 UTC
    HEAD
      .
      .
      .
    TAIL
    and ends with suppose 
    America 331
    
    If your file looked something like what is above, you could do the following:
    my $read = 1; my @output; foreach my $line (@array){ if($line =~ /HEAD/){ $read=0; } elsif($line =~ /TAIl/){ $read=1; } push @output, $line if $read; }
    --eric
        Thank you guys, but I am trying to match the arrays here. If I want define 7 then it should recognize array 7 of another file and print some thing like
        define 7 thankx(#came from another file)
        . I couldn't find anywhere.
        Thankx.