Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Retunining hash values from subroutines

by bart (Canon)
on Jun 20, 2013 at 10:51 UTC ( #1039942=note: print w/replies, xml ) Need Help??

in reply to Retunining hash values from subroutines

There are a few things wrong with your approach.
  1. You return the hash when you match a line for a single user
    Instead, put the return statement at the end of the sub.
  2. You replace the contents of the hash for each user
    Instead, add a single entry in the hash for each user doing this:
    $UID_PATH{$USER} = $UID[5];

For optimization you could decide to return the hash ref, \%UID_PATH instead of a flattened list, but then you'd have to fix the script to use a hashref instead ofa hash, everywhere. (In languages like PHP and Javascript, there is no difference between a hash ref (or a hash. (AKA "associative array" in PHP and "object" in Javascript)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039942]
[virtualsue]: holli about half
[choroba]: "Tatsächlich, das ist die Knochenstruktur eines Bettlers!" ??
shmem bows. Thank you
[marto]: slowclap.gif
[marto]: animated gif in question...
[1nickt]: Interesting article on the Coming Software Apocaplyse that I found while following one of eyepopslikeamosqui to's posts. Posits that no one can guarantee the quality of, or even understand, the 100 million lines of code in a mo
[holli]: you know, monk days are fun and all. but too many of them are bad for your health
[1nickt]: ...modern car. Suggests using TLA+ or other software modeling language to autogenerate code.
1nickt is not sure more and more layers separating the programmer from the program is the right way to go...
[holli]: happy one, shmem ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-11-21 12:56 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (301 votes). Check out past polls.