Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

by poj (Prior)
on Mar 30, 2013 at 08:35 UTC ( #1026253=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?

try changing
} elsif ($rfv == 'HASH') {
} elsif ($rfv eq '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:46 UTC
    Sorry, that was a last minute change. In order to simplify the code for inclusion here, I left out a trivial optimization where I convert HASH to an integer:
    use constant Array => 1; use constant Hash => Array << 1; our %_typemap=(ARRAY=>Array, HASH=>Hash); sub _Var ($$$;$) { # Wrkhorse code for manu +fctrd Vars my ($__, $p, $vn, $wa)=@$_; $_=$__; # must not trash '$_' my $v = $p->{$vn}; # value my $rfv = ref $v; # type(ref) of var my $rfvi = $_typemap{$rfv} || 0; my ($arg, $addrof); if ($wa && $wa eq '&#945;') { $wa=undef, $addrof=1 } if (@_ && !$addrof) { # arg for "setter" $arg = shift; my $refarg = ref $arg; # ref of the arg unless ( defined($p->{$vn}) && defined $arg ){ # unless both de +fined $p->{$vn} = $arg; } elsif ($rfvi == Array) { ## if type(var)==ARRAY, +1 param if ($refarg ne "ARRAY" || (@$arg || @$v)) { push @{$p->{$vn}}, $_[0]; ## convert to "push" } } elsif ($rfvi == Hash) {
    I tried to cut down the amount of code included by cutting out the integer thing...sorry. I didn't want to get dinged for not trying to cut things down...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026253]
[Corion]: I just found out that in $current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ...
[Corion]: ... of the situation is :-)
[marto]: it's good to know that things can always get worse :P
[hippo]: Ignorance can be bliss
[Corion]: hippo: Yeah - I'll just avoid the project lead :)
[Corion]: marto: Yeah, it helps with the perspective :-D

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-07-26 08:13 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (385 votes). Check out past polls.