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


In reply to Wrapper method not returning same result as calling method directly by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.