in reply to Re: 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
> perl use strict; use warnings; use diagnostics; sub myprint { my( $fh, $text ) = @_; print $fh $text; } sub STDOUT { print "Woops!\n"; } myprint( *STDOUT, "Hello world!\n" ); __END__ Hello world! >
I'd rather prefer to be able to disable/deprecate indirect object syntax ...
...but unfortunately this doesnt work :(
nor this> perl my $x=\*STDOUT; $x->print("hu hu"); __END__ Can't locate object method "print" via package "IO::Handle" at - line +2.
> perl open my $x, ">", "/tmp/tst"; $x->print("hu hu"); print `cat /tmp/tst`; __END__ Can't locate object method "print" via package "IO::Handle" at - line +2.
Cheers Rolf
(addicted to the Perl Programming Language)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: why is it considered good syntax to put \* before STDIN or STDOUT
by Anonymous Monk on Jun 08, 2014 at 20:32 UTC | |
by LanX (Saint) on Jun 08, 2014 at 20:52 UTC | |
by Laurent_R (Canon) on Jun 09, 2014 at 06:37 UTC | |
by mr_mischief (Monsignor) on Jun 09, 2014 at 14:00 UTC |