[tpm] Fast(er) way of deleting X lines from start of a file

Uri Guttman uri at StemSystems.com
Thu Oct 1 09:31:02 PDT 2009


>>>>> "MK" == Madison Kelly <linux at alteeve.com> writes:

  MK> Uri Guttman wrote:

  >> this is a file system problem, not a perl one. the file system (other
  >> than on things like vms) doesn't allow deleting from the front of the
  >> file. it has to be copied in and out with the edits being done on the
  >> fly. there are many perlish ways to do this including tie::file, reading
  >> line by line and printing but ignoring the early lines using $. and
  >> slurping in the whole file (file::slurp::read_file) into an array,
  >> splicing off the lines and printing it out again (with
  >> file::slurp::write_file).

  MK> Hrm, I wasn't thinking about this at the file system level. I wonder
  MK> then if shell tools will in fact be any faster than pure-perl
  MK> implementations if they all need to read in -> write out the full file
  MK> behind the scenes.

specialized unix tools written in c will almost always be much faster
than perl if they are doing what they do best. that is always the
difference between a general purpose language vs a focused tool.

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


More information about the toronto-pm mailing list