loris has asked for the wisdom of the Perl Monks concerning the following question:
Hello Shavenheaded-Ones,
Instead of doing something like
my @fields = split(/;/); my $obj = SomeClass->new(this => "$fields[0]", that => "$fields[1]", the_other => "$fields[2]", );
I would like to do something like:
my @fields = qw/this, that, the_other/; my %argsHash = ???; my $obj = SomeClass->new(%argshash);
Now that the various copies of the Perl CD Bookshelf on the Internet seem to have be knobbled, I couln't find out how to initialise the hash properly.
Can anymonk help?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash initialisation
by Happy-the-monk (Canon) on Nov 19, 2004 at 10:23 UTC | |
|
Re: Hash initialisation
by davorg (Chancellor) on Nov 19, 2004 at 10:34 UTC | |
|
Re: Hash initialisation
by gothic_mallard (Pilgrim) on Nov 19, 2004 at 10:26 UTC | |
|
Re: Hash initialisation
by Eimi Metamorphoumai (Deacon) on Nov 19, 2004 at 14:49 UTC |