Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Or, how to make this work in Perl: create a function x() that can return an unblessed scalar, or an object if it is tried to be called as an object. For example:
print makeupname(); # prints "John Smith" print makeupname()->first; # prints "John"
Is it possible?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there a wantobject like wantarray?
by choroba (Cardinal) on Sep 25, 2014 at 15:45 UTC | |
by LanX (Saint) on Sep 25, 2014 at 15:49 UTC | |
by tobyink (Canon) on Sep 26, 2014 at 00:31 UTC | |
by LanX (Saint) on Sep 26, 2014 at 08:14 UTC | |
by tobyink (Canon) on Sep 26, 2014 at 09:00 UTC | |
| |
|
Re: Is there a wantobject like wantarray?
by Anonymous Monk on Sep 25, 2014 at 15:39 UTC | |
by Your Mother (Archbishop) on Sep 25, 2014 at 16:01 UTC | |
by LanX (Saint) on Sep 25, 2014 at 16:18 UTC | |
by Your Mother (Archbishop) on Sep 25, 2014 at 16:27 UTC | |
by LanX (Saint) on Sep 25, 2014 at 16:40 UTC | |
| |
|
Re: Is there a wantobject like wantarray?
by Anonymous Monk on Sep 26, 2014 at 01:15 UTC |