Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

tell() on sysread()

by perlcapt (Pilgrim)
on Oct 25, 2004 at 15:34 UTC ( #402249=perlquestion: print w/replies, xml ) Need Help??
perlcapt has asked for the wisdom of the Perl Monks concerning the following question:

I'm having problems getting tell() to return a value other than 0 after doing a sysread().
# in a loop after appropriate open $bytes = sysread($self->{FH},$self->{buffer},1024); print tell($self->{FH}),"\n";
$bytes is a lovely 1024, and there is good stuff in the buffer, but tell() is always returning 0; Is it my reference to a filehandle which works fine for sysread, but not for tell?
perlcapt
-ben
Update: merlyn explains why it doesn't work. The manual says to use sysseek(FH,0,1) which returns the offset just as implied. Problem understood and solved

Replies are listed 'Best First'.
•Re: tell() on sysread()
by merlyn (Sage) on Oct 25, 2004 at 15:41 UTC
      are you certain? beacuse the following works for me
      perl -e'open FH,"<test.pl"||die$!;$fh=\*FH;sysread($fh,$foo,256); $bar=tell($fh);print"$foo\n$bar\n";'
        Yet it fails miserably on Win32. The side-effects of using sysread are system-specific.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://402249]
Approved by tinita
help
Chatterbox?
erix counts their toes
[erix]: DBD::Pg 3.6.1 test has 'die;' then dies and fails wtf... (just below connect_database()
[erix]: I'm wondering what the idea could have been...
erix expletives
[shmem]: erix: counting them I get 20. What about you?

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2017-05-23 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?