in reply to Re^2: why is it considered good syntax to put \* before STDIN or STDOUT
in thread why is it considered good syntax to put \* before STDIN or STDOUT

I'm testing with the Arch Linux system Perl and, unless I'm missing something, it seems that both of your examples that "don't work", work for me.

$ perl my $x = \*STDOUT; $x->print("STDOUT test"); STDOUT test $ perl open my $x, '>', "/tmp/tst"; $x->print("blah blah"); $ cat /tmp/tst blah blah $ perl -v This is perl 5, version 20, subversion 0 (v5.20.0) built for x86_64-li +nux-thread-multi
  • Comment on Re^3: why is it considered good syntax to put \* before STDIN or STDOUT
  • Download Code

Replies are listed 'Best First'.
Re^4: why is it considered good syntax to put \* before STDIN or STDOUT (perldelta)
by LanX (Saint) on Jun 08, 2014 at 20:52 UTC
    Thanks for testing!

    ...must have been fixed in the meantime! (?)¹

    > perl -v This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

    to which class does $x belong to? still IO::Handle ?

    ... ARGHHHH ...

    Did you explicitly use IO::Handle ?

    My examples work now after importing.

    > perl use IO::Handle; my $x=\*STDOUT; $x->print("hu hu"); __END__ hu hu

    update

    ¹) 5.12.0/perldelta.html#Other-potentially-incompatible-changes

    Filehandles are now always blessed into IO::File .

    The previous behaviour was to bless Filehandles into FileHandle (an empty proxy class) if it was loaded into memory and otherwise to bless them into IO::Handle .

    Cheers Rolf

    (addicted to the Perl Programming Language)

Re^4: why is it considered good syntax to put \* before STDIN or STDOUT
by Laurent_R (Canon) on Jun 09, 2014 at 06:37 UTC
    Did you try these examples with the use strict; and use warnings; pragmas turned on?

      I just tested with 5.16.2 on OSX and it worked fine under strictures and warnings.