in reply to Pattern match....

Update: One should read the whole problem description before running into conclusions...

Update2:If you require only the first block and not all select statements, then in addition to the examples in my post you would have to recognize when to stop collecting lines from the input.

You go through the input line by line and select only those lines that are of interest. Something along these lines:

# Reading from a prepopulated array my @wanted; foreach my $line ( @input ) { push $line, @wanted if $line =~ /^SELECT poid/; }

or

# Reading from a filehandle my @wanted; foreach my $line ( <$input_fh> ) { push $line, @wanted if $line =~ /^SELECT poid/; }

or

my @wanted = grep { /^SELECT poid/ }, @input;

Note, all code is untested.

--
seek $her, $from, $everywhere if exists $true{love};

Replies are listed 'Best First'.
Re^2: Pattern match....
by Anonymous Monk on Jan 21, 2009 at 08:29 UTC
    hi... its showing an error.as mentioned below, Type of arg 1 to push must be array (not private variable) . in the line , push $line, @wanted if $line =~ /^SELECT poid/;

      Ah, the push arguments are in wrong order, my memory played a trick with me. The correct order would be:

      push @wanted, $line if $line =~ /^SELECT poid/;
      --
      seek $her, $from, $everywhere if exists $true{love};