Using perldoc -q tail
leading to
perldoc -f seek
perldoc -f tell

I'm not getting how to use those functions.  Partly because what
passes for examples in those docs doesn't use normal language, instead
they use terms like WHENCE, something that's almost never used in
normal language.  When WHERE would get the point across at a glance
instead of having to dig into the details,

At first I took it to mean something more involved than giving a
possition.
No biggee I guess  but then I see:

                   for (;;) {
                       for ($curpos = tell(FILE); $_ = <FILE>;
                            $curpos = tell(FILE)) {
                           # search for some stuff and put it into files
                       }
                       sleep($for_a_while);
                       seek(FILE, $curpos, 0);
                   }

Even here what the heck does `;;' mean.  This stuff is supposed to be
readable by someone who doesn't know these things.  Even down to
`curpos'.  I didn't get what it meant for a few seconds.  Why not
spell it out... $CurrentPostion.  After all clarity is what we're
after here.

Again no biggee I guess, 

However, I still don't see how it is supposed to work.  Is there a law
against simple examples? hehe.
 (ok enough complaining ...)

seek documentation indicates the for loop probably won't be necessary
unless the IO implementation is `particularly cantankerous'.  So I'm
guessing there is some easier way to access the stuff below where I've
told the interpreter to seek to.

It left me thinking something like this should work but it absolutely
fails to print tell() from seek(FILE, -($bytes -100) ,2) position.

use strict;
use warnings;

my $bytes;
open(FILE,">>./myfile")or die " Can't open ./myfile: $!";
     $bytes = tell(FILE);
   print "hpdb pre seek bytes <$bytes>  \n";
print FILE "line\nline\nline\nline\n";

## go back to 100 bytes before previous end of file.
seek(FILE, -($bytes -100) ,2);
while(<FILE>){ 
   print "hpdb tell by line:" . tell(FILE) . "\n";
}
close(FILE);


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to