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

Re: Questions about the my Foo $var syntax

Thread Previous | Thread Next
From:
"Ruud H.G. van Tol" via perl5-porters
Date:
March 13, 2023 11:58
Subject:
Re: Questions about the my Foo $var syntax
Message ID:
cd0a9d15-3060-51fc-1cc7-d9077f03c979@isolution.nl

On 2023-03-13 12:29, Robert Rothenberg wrote:
> There's some legacy syntax still used in some very old code bases, 
> e.g. TheSchwartz
>   my TheSchwartz::Job $job = shift;
> As far as I can tell, this doesn't do anything except require that 
> TheSchwartz::Job namespace exists. It doesn't require $job to be a 
> TheSchwartz::Job.

See also `perldoc fields`.

-- Ruud


perl -Mstrict -wE'
   use Data::Dumper; {package Data::Dumper; our 
($Indent,$Sortkeys,$Terse,$Trailingcomma,$Useqq)=(1)x5}
   sub T_Int { print __PACKAGE__, "::T_Int: ", Dumper(\@_); $_//= \1 for 
@_ }
   T_Int my ($x, $y);
   print "[x,y]=", Dumper([$x, $y]);
'

main::T_Int: [
   undef,
   undef,
]
[x,y]=[
   \1,
   $VAR1->[0],
]


Thread Previous | Thread Next


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