Why should I switch to Python?
Dan Schmidt
dfan at harmonixmusic.com
Thu May 11 16:57:45 EDT 2000
Paul Winkler <slinkp23 at yahoo.com> writes:
| The key line is this, in my version:
|
| for f in friends[name]:
|
| Your version:
|
| for $f (@{ $friends{ $name } }) {
|
| > Of course, the de-referencing of the array reference looks bizarre,
| ^^^^^^^^^^^^^
|
| Yes, it does. :) More to the point, I got too frustrated with
| staring at man perldsc and man perllol trying to understand it. Can
| you explain the meaning of each bit of punctuation on that line?
This is the wrong newsgroup, I realize, but I thought I should share
the Rule That Makes Using Perl References Easy (well, straightforward,
at least): Wherever you can normally use a raw variable name (sans
punctuation prefix), you can use a reference. e.g.,
${$ref} (or $$ref) is 'the scalar $ref' just as $foo is 'the
scalar foo'.
@{$friends{$name}} is 'the array $friends{$name}' just as @foo is
'the array foo'.
That said, I like Python better than Perl too (except for ten-line
text-munging programs).
--
Dan Schmidt | http://www.dfan.org
More information about the Python-list
mailing list