which fails to find your new method in package main because main is being interpreted as a glob, not as a class name. The following snippet fixes that for some values of fix (as long as you don't later want to use IO::Handle of course).perl -e 'sub new {die@_} main->new(); open main, "foo"'
Of course if in package IO::Handle you were to open a filehandle named CGI, then the workaround stops working...
package IO::Handle; sub new { *{shift(@_)}{NAME}->new(@_); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Unconfuse filehandles and classes
by tye (Sage) on Aug 30, 2001 at 21:50 UTC | |
by tye (Sage) on Aug 31, 2001 at 03:05 UTC | |
by bbfu (Curate) on Sep 07, 2001 at 00:07 UTC |