Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

$io->autoflush - which perl version?

by Doug_H (Initiate)
on Mar 27, 2016 at 19:39 UTC ( [id://1158898]=perlquestion: print w/replies, xml ) Need Help??

Doug_H has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I would like to use $io->autoflush(1)from IO::Handle. Unfortunately it looks like in perl v5.10.0 it is not included in the core module. It works fine with version 5.16.2.

Therefore I have 2 questions and hopefully you can help me.

1) Which perl version did add autoflush to the default core module?

2) How can I implement it that it is activated when the method is there. Something like this …

if (v.5.x.x. or higher) } $io->autoflush(1); }

For any other ideas how I can solve that it works with 5.10.0 and all newer versions I would be very happy - thanks.

Thanks for your help.

Kind regards

Doug EDIT:

Sorry ... it looks like that it works when I add use IO::Handle;.

It is not necessary with version 5.16.2 but required for 5.10.0 ?!

Any idea why the different behaviour?

Replies are listed 'Best First'.
Re: $io->autoflush - which perl version?
by choroba (Cardinal) on Mar 27, 2016 at 19:53 UTC
    See the delta for 5.12:

    > Filehandles are now always blessed into IO::File

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: $io->autoflush - which perl version?
by Anonymous Monk on Mar 27, 2016 at 19:53 UTC
    AFAIK for $io->autoflush(1); to work you just have to add use IO::Handle; at the top of your code; should work all the way back to at least 5.8. Perl 5.14 and up loads IO::Handle automatically, which is why the "autoflush" method "just works" there.

    The command "corelist IO::Handle" says "IO::Handle was first released with perl 5.00307".

    The other kind of kludgy but AFAIK backwards-compatible way to set autoflush on a handle is { my $tmp = select($io); $| = 1; select($tmp) }.

    And your "if" statement could be written like this: if($] lt "5.008") ...

Re: $io->autoflush - which perl version?
by zwon (Abbot) on Mar 27, 2016 at 21:49 UTC
    It will work in 5.10 too if you add use IO::Handle
Re: $io->autoflush - which perl version?
by stevieb (Canon) on Mar 27, 2016 at 19:50 UTC

    1) looks like v5.14.

    2) I think $| = 1; is what you want. See perlvar.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1158898]
Approved by graff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found