gepebril69 has asked for the wisdom of the Perl Monks concerning the following question:
But what is I get an hash returned from a subroutines with new firstname, famname, street results, likemy @NameArray; $NameArray[0]{firstname} = "Jan"; $NameArray[0]{famname} = "Jansen"; $NameArray[0]{street} = "ParkAvenue";
And I would like to add it directly to that array likesub addnaw { # In real a subroutine which collects a specific line # from a file my %value $value{firstname} = "John"; $value{famname} = "Johnson"; $value{street} = "Bellpark"; return %values; }
Which does not work, is it possible, or do I have to use more code.my @NameArray; for ($i; $i < $endvalue; $i++) { NameArray[$i] = addnaw(); # Fault code }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to create an array of hashes return form a subroutine
by roboticus (Chancellor) on Mar 26, 2012 at 15:15 UTC | |
|
Re: How to create an array of hashes return form a subroutine
by tangent (Parson) on Mar 26, 2012 at 15:16 UTC | |
by gepebril69 (Scribe) on Mar 26, 2012 at 16:20 UTC | |
|
Re: How to create an array of hashes return form a subroutine
by JavaFan (Canon) on Mar 26, 2012 at 15:36 UTC | |
|
Re: How to create an array of hashes return form a subroutine
by stevieb (Canon) on Mar 26, 2012 at 15:31 UTC |