in reply to Re: Method for reducing tedium of transferring object properties to scalars
in thread Method for reducing tedium of transferring object properties to scalars

my best guess is that you want something like a with(object){ } statement like in JS...

Oh! great oppotunity for being silly...

package Foo { sub new { bless { foo => 'bar', baz => 'quux', }; } sub get_foo { $_[0]->{foo}; } sub get_baz { $_[0]->{baz}; } } sub with (&$@) { my $code = shift; my $obj = shift; map { my $meth = $_; local $_ = $obj->$meth; $code->(); } @_; } my $obj = Foo->new; my @methods = qw(get_foo get_baz); with { print "val: $_\n"; } $obj, @methods;

;-)

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
  • Comment on Re^2: Method for reducing tedium of transferring object properties to scalars
  • Download Code

Replies are listed 'Best First'.
Re^3: Method for reducing tedium of transferring object properties to scalars
by LanX (Saint) on Apr 22, 2017 at 10:55 UTC
    Roughly almost ... no ... almost roughly ...

    ;)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!