Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407974]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-05-25 07:08 GMT
Find Nodes?
    Voting Booth?