develooper Front page | perl.beginners | Postings from May 2007

Regarding files

Thread Next
Dharshana Eswaran
May 20, 2007 21:37
Regarding files
Message ID:
Hi All,

The below code helps in reading a file in reverse:

use strict;
use warning;

open( FILE, "<$file_to_reverse" )

  or die( "Can't open file file_to_reverse: $!" );

@lines = reverse <FILE>;
foreach $line (@lines) {
  # do something with $line

But i am trying to grep for a string in the file and once i get the string,

I need to read few lines which occurs before the string. For eg:

typedef union
    TYPE_T type;
   MODE_T mode;

Here, I grep for CHANNEL_INFO_T, once i get that, i need to read the
elements defined in the union or structure.

I have written a code but i am unable to achieve what i wanted.

Can anyone guide me in this?

Thanks and Regards,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About