Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: $io->can('seek') == true, but $io->seek(pos, whence) == 'Illegal seek' - bug ?

by leriksen (Curate)
on Nov 15, 2004 at 21:47 UTC ( #407974=note: print w/ replies, xml ) Need Help??


in reply to Re^3: $io->can('seek') == true, but $io->seek(pos, whence) == 'Illegal seek' - bug ?
in thread $io->can('seek') == true, but $io->seek(pos, whence) == 'Illegal seek' - bug ?

Thanx, that is a very lucid answer - I wasnt really happy with pg's answer a first, now I have no problems.

Update:Actually I had the drive to work to think about this and I'm less happy.

I understand this is not going to change, but the DWIM part of this still irks me.

I accept that if $io_obj->can('seek') is true I still need to check the return code of $io_obj->seek(pos,whence) because 'things can happen' (tm) like drives failing etc.

But I can't see how a stream can ever become seekable, so the true value from can() doesnt help the argument of perl DWIM.

So my final points are

  • stream based IO::Handle object should not inherit from IO::Seekable (but I understand that things will stay as they are)
  • I should have used my brain in the first place when I tried to seek on a stream (and I hope that becomes the default position)

use brain;


Comment on Re^4: $io->can('seek') == true, but $io->seek(pos, whence) == 'Illegal seek' - bug ?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407974]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-12-20 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls