--- Deb <[EMAIL PROTECTED]> wrote:
> Hmmm, that's a useful work-around.
>
> I may use it, but I'm really interested in finding out what the correct
> invocaton of "map EXPR, LIST" would be.
>
> Anyone know?
>
> Thanks,
>
> deb
The following line of code is bad:
map print ("\t\"$_\"\n"), @{$HashofLists{$List} };
What's really doing on is that the print is working, and the return value of print is
what is
"mapped". Since print returns 1 for success (and almost always succeeds), this means
that the map
is creating a list, with all elements equal to 1 (one) for each elements in the data
structure.
Creating this list only to throw it away just doesn't make much sense.
Here's some code that shows what's going on:
$ perl -MData::Dumper -e '@a=map print,qw/a b c/;print Dumper \@a'
abc$VAR1 = [
'1',
'1',
'1'
];
You can see the 'abc' prior the Data::Dumper output, and you can see that a list of
ones has been
created. The map only confused things. The code would be better written as:
print qq{\t"$_"\n} foreach @{$HashofLists{$List}};
I hope that answered your question.
Cheers,
Ovid
=====
"Ovid" on http://www.perlmonks.org/
Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/
Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]