in reply to end of file!

Dear Mr. pandey..If you first find the size of the file & then read the last 100-200 bytes or so..then try to find if there is a newline character in these bytes..if yes go ahead to split this with newline character and then take the last part(in case the end of line is new line character else any-way you can fix the input record seperator as reqd.) In case you do not find it then read last 300 bytes or so and continue till you find it...In this way you'll need only the minimum memory reqd.finding the size of the file in bytes is trivial any-way. As youknow youmay use read(FILEHANDLE,VAR,LENGTH,OFFSET) for ex.. let us suppose you have a file of 5000bytes.. now to get the last 100 characters from it
#!usr/local/bin/perl open(FILE ,"name_of_the_file_to_be_read"); seek(FILE, 4900,0); read(FILE,$ab,100); #note the last 100 bytes get stored in $ab close(FILE);
Now you can very well check for the newline character in $ab and then No need of any Module etc.... isn't it?? -MRT

Replies are listed 'Best First'.
RE: Re: end of file!
by vnpandey (Scribe) on Jul 26, 2000 at 19:26 UTC
    Wow!! It really works... Thanks..This seems to be one of the the smartest way one could think of!!! Thanks a lot......... :-Pandey