Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^5: How to return values from a hash?

by BrowserUk (Pope)
on Mar 30, 2013 at 04:38 UTC ( #1026236=note: print w/replies, xml ) Need Help??

in reply to Re^4: How to return values from a hash?
in thread How to return values from a hash?

Unless I am getting very short-sighted, _Var() is never called by either by_mp() or lvm_BaseDiff_Lvh_4_Base_opt_mp(), so why are you attributing the error to the return from that subroutine?

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: How to return values from a hash?

Replies are listed 'Best First'.
Re^6: How to return values from a hash?
by perl-diddler (Hermit) on Mar 30, 2013 at 14:52 UTC
    Um...._Var is the generic that is called for all of the 'named' vars...

    I have a sub '_access_maker' that defines subs for each name in the field, those access routines all push on context and call Var.

    If you wish to see it, it's fairly old code and probably could be optimized a bit...but it works...

    sub varname ($) { substr $_[0], (1+rindex $_[0],':') } sub _access_maker { #{{xo{2 my $pkg = shift; #var in $_ { #TPe "(Dvam: %s::%s() )\xc2\x83",$pkg,$_; my $proc = '# line ' . __LINE__ . ' "' . __FILE__ . "\"\n" . ' { use warnings;use strict; package '.$pkg.'; sub '.$_.' (;$) { # create access routine for packa +ge::var $_=[$_,shift, Data::Vars::varname((caller 0)[3]), wantarray] +; goto &Data::Vars::_Var}; 1}'; eval $proc; $@ and die "Fatal error in $pkg\::Vars\::_access_maker?: $@\n"; } } ## end sub _access_maker }}}2

    So _access_maker is called at compile time to define 'sub's for each of the the 'field' vars. So the code during execution is not _access_maker, but the sub...#create access routine for package::var You can see why I didn't bother including it... It's just a push of context and then a goto _Var

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026236]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-02-18 05:45 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (250 votes). Check out past polls.