perl - Sum multiple keys of hash in one line -


i need sum differents keys of hash in 1 line instead of using foreach.

if have hash:

%a = (  => 4,  b => 3,  c => 7,  d => 2,  e => 4 ); 

for example: $a{a d e} output: 10

it possible or need foreach??

thanks

possible hash slice notation

use list::utils 'sum'; $the_sum = sum( @a{"a","d","e"} ); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -