Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
At the bottom of the call stack, is a 'Vars' routine to wrap fields in a hash. The relevant parts:
sub _Var ($$$;$) { # Wrkhorse code for manu +fctrd Vars #note $p->obj, $vn=varname, $wa=wantarray val my ($__, $p, $vn, $wa)=@$_; $_=$__; '$_' my $v = $p->{$vn}; # value my $rfv = ref $v; # type(ref) of var ...... } elsif ($rfv == 'HASH') { my $subvar=$arg; ## 1 var w/hash is is a key $p->{$vn}{$subvar}=$_[0] if @_; ## another? =>assign va +lue return $p->{$vn}{$subvar}; <- returns has here.
That is called in sub 'by_mp' that takes care of init stuff and handles accessing the field: _by_mp in this case:
sub by_mp(;$) { my $map = shift; my $c = ref $map || $map; ...init... my $arg_lvh = $map->_by_mp($arg); if (ref $arg_lvh) { $arg_lvh->fs_mp($arg); return $arg_lvh; #<----seems to return from here } my $devno = (stat $arg)[0]; $arg_lvh = $map->by_devno($devno); return undef unless $arg_lvh; die P "by_mp: by_devno(%s) returned %s, of type \"%s\", not a ref\ +n", $devno, $arg_lvh, ref $arg_lvh unless ref $arg_lvh; $map->_by_mp($arg, $arg_lvh); $arg_lvh->fs_mp($arg); return $arg_lvh; }
That is called in the level of code where I detect the problem:
sub lvm_BaseDiff_Lvh_4_Base_opt_mp ($;$) { my $lvm = shift; my ($base_lvh, $lv_mp) = @_; my $diff_dev = pathcat("/dev", $base_lvh->vg_name, $base_lvh->lv_name . ".diff"); #TPe "diff_dev=%s", $diff_dev; # next is call to by_mp -- here is where I don't seem to be #getting a reference back. my $bdiff_lvh = $lvm->by_mp($lv_mp.".diff") if @_; $bdiff_lvh = $lvm->by_devpath($diff_dev) unless ref $bdiff_lvh; ## commented version below was orig -- trying above -- ## seems to work better, but seems a bit random... #my $bdiff_lvh = (@_ && $lvm->by_mp($lv_mp . ".diff") or # $lvm->by_devpath($diff_dev)); die P "Can't find \"diff\" dir for vol %s by mount or device path" +, $lv_mp unless ref $bdiff_lvh; $bdiff_lvh->fs_mp($lv_mp) unless $bdiff_lvh->fs_mp; $bdiff_lvh->fs_type_name($base_lvh->fs_type_name) unless $bdiff_lvh->fs_type_name;

In reply to Re^4: How to return values from a hash? by perl-diddler
in thread How to return values from a hash? by perl-diddler

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (6)
    As of 2015-07-07 03:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (87 votes), past polls