in reply to Re: get the line of ith occurrence of '>' without OPENING THE FILE
in thread get the line of ith occurrence of '>' without OPENING THE FILE

If open fails mysteriously (and you have no idea what the error message might be - you should inspect $! but others pointed this out already), you might try the sysopen() and sysread() family.

Here you can use a buffer with a certain length and read that number of bytes at a time into thiis buffer.

OTOH, If the problem is that you can not split on the default line endings, you might also try setting $/ to something more suitable (e.g. when the file doesn't contain newlines and you're reading a line at at time).

{ local $/ = '>'; # you were looking for this one, right? open(FILE, "bigfile.big") or die $!; while (<FILE>) { # do interesting stuff # e.g. merely count lines... } close FILE; }

--
Cheers, Joe

  • Comment on Re: Re: get the line of ith occurrence of '>' without OPENING THE FILE
  • Download Code