Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Indirect Object Syntax

by choroba (Archbishop)
on Nov 06, 2021 at 20:48 UTC ( #11138528=note: print w/replies, xml ) Need Help??


in reply to Indirect Object Syntax

Short demonstration of the problem:

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; sub new {} { package MyObj; sub new { bless { name => $_[1] }, $_[0] } sub string { join ', ', values %{ $_[0] } } } say 'MyObj'->new('obj1')->string; say new MyObj('obj2')->string;
This works as expected.
obj1 obj2

Now try moving the package definition to the end of the code.

obj1 Undefined subroutine &main::MyObj called at ... line 9.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-05-26 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (92 votes). Check out past polls.

    Notices?