Why does the relative positioning of these code elements matter?
C:\test>type t-Moose.pl #! perl -slw use strict; { package test; use Moose; has x => ( is => 'rw' ); sub doit { my( $self ) = @_; print $self->{ x }; print ${ $self->{ x } }; } } our @c = 12345; my $o = test->new( x => \$c[ 0 ] ); $o->doit; C:\test>perl t-Moose.pl SCALAR(0x229cd4) 12345
Invert the ordering and:
C:\test>type t-Moose.pl #! perl -slw use strict; our @c = 12345; my $o = test->new( x => \$c[ 0 ] ); $o->doit; { package test; use Moose; has x => ( is => 'rw' ); sub doit { my( $self ) = @_; print $self->{ x }; print ${ $self->{ x } }; } } C:\test>perl t-Moose.pl Use of uninitialized value in print at t-Moose.pl line 14. Can't use an undefined value as a SCALAR reference at t-Moose.pl line +15.
In reply to Do Mooses always want to face north? by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |