#! perl -slw use strict; use IO::Detect qw[ is_filehandle ]; sub funcTakesIO1 { my $fh = shift; if( is_filehandle( $fh ) ) { print $fh 'Bang!'; } return; } sub funcTakesIO2 { my $fh = shift; if( is_filehandle( $fh ) ) { return <$fh>; } return; } eval { funcTakesIO1( \*STDIN ); } or warn "IO::Detect detected the wrong thing"; eval { funcTakesIO2( \*STDOUT ); } or warn "IO::Detect detected the wrong thing"; __END__ C:\test>junk5 Filehandle STDIN opened only for input at C:\test\junk5.pl line 9. IO::Detect detected the wrong thing at C:\test\junk5.pl line 24. Filehandle STDOUT opened only for output at C:\test\junk5.pl line 18. IO::Detect detected the wrong thing at C:\test\junk5.pl line 28.