Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Has a filehandle been binmode'd

by fireartist (Chaplain)
on Feb 27, 2006 at 11:52 UTC ( #532999=perlquestion: print w/replies, xml ) Need Help??
fireartist has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to check whether binmode() has been called on a filehandle?

If not, I notice in the perl source file PerlIO/via/via.xs that there's a method PerlIO_modestr which might help, but I lack the tuits to look into this further. Any pointers appreciated.

Replies are listed 'Best First'.
Re: Has a filehandle been binmode'd
by borisz (Canon) on Feb 27, 2006 at 14:04 UTC
    See PerlIO and then the get_layers function.
    my @l = PerlIO::get_layers($fh, details => 1);
Re: Has a filehandle been binmode'd
by derby (Abbot) on Feb 27, 2006 at 13:53 UTC

    Hmmm ... well you could try Fcntl; however, it may not be supported on your platform:

    !#/usr/bin/perl use Fcntl; open( FH, "<", "/bin/cat" ) or die "cannot open file: $!\n"; $flags = fcntl(FH, F_GETFL, 0) or die "Can't get flags for the file: $ +!\n"; if( $flags | O_BINARY ) { print "OPEN FOR BINARY\n" }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://532999]
Approved by marto
Front-paged by bart
[Corion]: marto: I believe nowadays, at least window.opener should not be set anymore (except maybe within the same domain)
[Corion]: But I wouldn't really know as I don't use iexplore much (except at $work) and mostly surf with JS disabled (except at $work :) )
[marto]: yeah, this is at work, where some intranet app launches links via When users close the intranet page so that only the new JS opened windows exist, clicking URLs in an email (or whatever) don't open
[Corion]: marto: It somewhat makes sense that the reduced popup window doesn't get new URLs, but it makes less sense that no new browser window opens :)
[marto]: Corion, yeah, why no new browser window opens is currently beyond my understanding

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-03-21 11:49 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.