On Sun, Sep 09, 2001 at 12:18:22PM +1000, [EMAIL PROTECTED] wrote:
> The JAPH below is generated from this program:
>   open 0;
>   $/ = undef;
>   $x = <0>;
>   close 0;
>   $x =~ tr/!-~/#/;
>   print $x;
> I noticed this "zero file handle trick" in Acme::Bleach,
> but it does not seem to be mentioned in the docs.
> Does anyone have more information on this trick?

perlfunc:

  open FILEHANDLE,EXPR

  open FILEHANDLE

    Opens the file whose filename is given by EXPR, and associates it with
    FILEHANDLE.  If FILEHANDLE is an expression, its value is used as the
    name of the real filehandle wanted.  If EXPR is omitted, the scalar
    variable of the same name as the FILEHANDLE contains the filename.

perlvar:

  $0

    Contains the name of the file containing the Perl script being
    executed.

So, open(0) opens the filehandle 0 on the file named in the variable $0,
which happens to be the file that is being executed.


Ronald

Reply via email to