develooper Front page | perl.perl5.porters | Postings from March 2000

Filehandle name / use strict clash

From:
Johan Vromans
Date:
March 19, 2000 12:33
Subject:
Filehandle name / use strict clash
Message ID:
14549.13695.449375.833960@phoenix.squirrel.nl
Functions like 'print' have in their documentation:

    FILEHANDLE may be a scalar variable name, in which case the
    variable contains the name of or a reference to the filehandle,
    thus introducing one level of indirection.

However, the 'variable contains the name' variant is rejected when the
strict pragma is in effect (Can't use string ("F1") as a symbol ref
while "strict refs" in use):

    open (F1, ">foo1");
    my $f1 = "F1";
    print $f1 ("Hello");

I could not find this anywhere in the documentation, at least not in
the obvious places like with 'print' and friends.

-- Johan



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About