remove specific lines from flat file using perl

Hi,

Here is wat im looking for.. i have a flat file which looks like this..

00
*
*
*
*
..
..
*
*
text
text
text

COL1 COL2
----- -----
1 a
2 b
3 c
....
....
100 z

text
text
text
*
*
...
...
*

I just want to retrieve..

COL1 COL2
----- -----
1 a
2 b
3 c
....
....
100 z

(Looking for perl code)
Thanks,
Megha

can anyone help on this!!!

you can try to parse the contents of the file and compare the lines you are reading, maybey something like this (will require some polishing):

open(FH, $filename);

while (<FH>) {
print $_ if ($_ =~ / /);
}

in other words, will print the line if it contains a space, but it may be not what you are requiring, for that some more info may come in handy..

open(FILE,"<","Test.TXT");
while (my $line = <FILE>)
{
if ($line =~ /^*/){
print $line;
}
}
close(FILE);

Here is what i was trying to do to pick up the lines that start with '*' .. but its not picking up.. can you help me on this??

the * stands for "match 0 or more times", think you need to escape the *:

if ($line =~ /^\*/){

Thats works... i have a tab in the beginning of a line.. can you tell me how to represent a "tab" in a search string... i used ($line =~ m/^\/) && ($line =~ m/^\ /) .. respectively for a '' character and ' ' space.. need to work to get a "tab" too...

Thanks

****

Im unable to understand what kind of character is that.. the one which looks like a box.. i thought it was a tab.. but im not sure...
can anyone help me??...
thanks

a tab can be represented by a \t, or you can maybe use the syntax like

\s+ (one or multiple whitespace characters, spaces and tabs)..

when you google for "perl find metasymbols" you will find some more explaining about these options.

Thanks.. i will do a search on it..

Don't know what you exactly want, but sometimes is more easy to search for what you want than to exclude the things you don't want, remember there are many way's how you can solve the issues with perl.

im sorry about the last post.. it was some weird character i couldnt copy it properly... i have a question...
foreach my $file (@array) {
open(FILE,"<","$file");
while (my $line = <FILE>)
{
if ($line =~ /^*/){
print $line;
}
}
close(FILE);
}

im looking to print all the ripped contents from each file to other different files.. example... if im going through file1, file2, file3...filen .. im looking to write to file1_1, file2_1, file3_1, ... filen_1 .. something like that instead of print $line;

bare bones script:

open(my $in, 'infile.txt');
LOOP: while(<$in>){
   if (/COL1 COL2/) {
      print $_;
      while (<$in>) {
         print $_;
         last LOOP if (/100 z/);
      }
   }
}

see if you can figure out how to implement according to the rest of your requirements. If not, post back.

try to do some code next time.
one way.

#!/usr/bin/perl 
open(F, "<file") or die "cannot open file:$!\n";
while ( <F> ) {
 if ( /COL1 COL2/ .. /^$/ ) {
  print;
 } 
}
close(F);