> [EMAIL PROTECTED] - Fri Aug 12 18:18:40 2005]:
> 
> 
> This is a bug report for perl from [EMAIL PROTECTED],
> generated with the help of perlbug 1.34 running under perl v5.8.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
>         plover% perl -wle '$x="pq"; print readdir $x'
>         Bad symbol for filehandle at -e line 1.
> 
> But it should be
> 
>         Bad symbol for dirhandle at -e line 1.
> 

A heuristic.  What does Klortho say about that...

  #11953 Of course, this is a heuristic, which is a fancy way of saying
that it doesn't work.

This error message above comes from the following code in gv.c

GV *
Perl_gv_IOadd(pTHX_ register GV *gv)
{
    if (!gv || SvTYPE((SV*)gv) != SVt_PVGV)
        Perl_croak(aTHX_ "Bad symbol for filehandle");
    if (!GvIOp(gv)) {
#ifdef GV_UNIQUE_CHECK
        if (GvUNIQUE(gv)) {
            Perl_croak(aTHX_ "Bad symbol for filehandle (GV is unique)");
        }
#endif
        GvIOp(gv) = newIO();
    }
    return gv;
}

Unfortunately, it assumes all typeglobs are filehandles.  That means the
following code works, well prints nothing at least, without warning.

perl -Mstrict -wle 'my $x="pq"; *X = $x; print readdir X'

It also means that, since there doesn't seem to be a way to distinguish
between filehandles and dirhandles, the following also runs without
warnings.

perl -Mstrict -wle 'open X, "foo"; print readdir X'


Reply via email to