Hi,

Is there a way for a subroutine to tell when it got passed a FILEHANDLE?

Running a quick test suggests a way, which is to check the first char of the result of 
interpolating the subroutine param as a string.  Can anyone say whether this is robust 
and if not what might be a better approach?  Thank you.

    testprintorstring.pl:
    ---------------------

    use warnings;
    use strict;

    {
        my $string = "xyz";
        testprint( "Filehandle", *STDIN );
        testprint( "Stringref", \$string );
    }

    sub testprint {
        my( $descr, $r_data ) = @_;
        print "$descr: $r_data ", ref($r_data), "\n";
    }

    output:
    -------

    D:\MCD\dvl\scripts>perl testprintorstring.pl
    Filehandle: *main::STDIN
    Stringref: SCALAR(0x155a898) SCALAR




__________________________________________________________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to