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; } CHANNEL_INFO_T; 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, Dharshana