nysus has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: OK, someone shoot me. I stupidly changed the function to put the return value as the croak statement. I need some sleep. Someone please delete this.
Monks, I'm stumped on something that's probably pretty obvious but is escaping me. I'm wondering if I can please get second pair of eyes because this is driving me crazy.
So this works fine:
$cmd = qq(perl -e "print ((stat '$path')[4])"); my $uid = $self->ssh->capture($cmd);
$self->ssh is a Moose attribute containing a Net::OpenSSH object (see below). $uid returns an expected "1000."
However, when I call the same command with my grab wrapper method for the Net::OpenSSH:
$cmd = qq(perl -e "print ((stat '$path')[4])"); my $uid = $self->grab($cmd); { package MyOpenSSH 0.000001; use Carp; use Data::Dumper; use Moose::Role; use Modern::Perl; use Net::OpenSSH; use Params::Validate; has 'ssh' => (is => 'rw', isa => 'Net::OpenSSH', required => 1, lazy + => 0, handles => qr/.*/, ); sub grab { my $self = shift; my $opts = shift; $self->ssh->capture($opts, @_); croak ('ssh command failed') if $self->ssh->error; } }
the $uid is set to '0'. What am I missing?
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wrapper method not returning same result as calling method directly
by trippledubs (Deacon) on Mar 16, 2017 at 01:48 UTC | |
by nysus (Parson) on Mar 16, 2017 at 02:34 UTC | |
by stevieb (Canon) on Mar 16, 2017 at 02:52 UTC | |
|
Re: Wrapper method not returning same result as calling method directly
by Anonymous Monk on Mar 16, 2017 at 01:42 UTC | |
by stevieb (Canon) on Mar 16, 2017 at 02:34 UTC |