>>>>> "MGS" == Michael G Schwern <[EMAIL PROTECTED]> writes:


  MGS>     use File::ReadBackwards;
  MGS>     open F, $ARGV[0] or die;
  MGS>     tie *G, 'File::ReadBackwards', $ARGV[0] or die;

  MGS>     while(1) {
  MGS>         $front = <F>;
  MGS>         last if $front eq $back;
  MGS>         $back = <G>;
  MGS>         last if $front eq $back;
  MGS>     }
  MGS>     print $front;        
        

damn, i was thinking about using my module for it. but you have a bug.
what if the file looks like this:

foo
bar
blucher
middle
garbage
bar
blech

your code would print 'bar'


a fix is would be to check when the locations in the file are the same
and stop. but File::ReadBackwards doesn't support tell (it does its own
buffering but maybe it could. does Tie::Filehandle have a TELL/SEEK method?)

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
              • ... Chris Thorpe
              • ... Michael G Schwern
              • ... Uri Guttman
              • ... Michael G Schwern
              • ... Sam Holden
              • ... abigail
            • ... abigail
              • ... Michael G Schwern
          • ... Uri Guttman
          • ... abigail
      • ... Uri Guttman
        • ... Michael G Schwern
          • ... Uri Guttman
      • ... Ariel Scolnicov
      • ... abigail
  • ... Ian Phillipps
  • ... Yanick
  • ... Greg Bacon
    • ... Michael G Schwern
      • ... Dmitry Kohmanyuk Дмитрий Кохманюк
        • ... Greg Bacon

Reply via email to