in reply to hash from sub directly into foreach loop
should be%s{'a'} = 10 ; %s{'b'} = 20 ; %s{'c'} = 30 ;
anyway, the following change will work for you:$s{'a'} = 10 ; $s{'b'} = 20 ; $s{'c'} = 30 ;
hope this helps,#!/usr/bin/perl use strict ; use warnings ; foreach ( keys %{&testa} ) { print "key is $_\n" ; } sub testa { my $s = () ; $s->{'a'} = 10 ; $s->{'b'} = 20 ; $s->{'c'} = 30 ; return $s ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash from sub directly into foreach loop
by GrandFather (Saint) on Jun 30, 2006 at 11:30 UTC | |
|
Re^2: hash from sub directly into foreach loop
by jeanluca (Deacon) on Jun 30, 2006 at 08:23 UTC | |
by gellyfish (Monsignor) on Jun 30, 2006 at 10:58 UTC | |
by Corion (Patriarch) on Jun 30, 2006 at 08:32 UTC |