DCPM: De-SWENing
Matthew Browning
mb at matthewb.org
Sun Sep 21 03:30:25 CDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 20 September 2003 20:30, Simon Waters wrote:
> One thing I still find tricky is what to prefix variables with in
> Perl.
>
> Am I right in thinking that Net::POP3 ->list() is returning a
> reference to a hash, not a hash, hence the $mail->{$msg}, as
> programmers seem to say "returns a has" when they mean "returns a
> reference to a hash", or am I just showing my lack of sleep :(
>
What you've done is right. Net::POP3->list does return a reference to
a hash (see line 201 of the module). You correctly iterate over the
keys to assign the corresponding value to $size in your loop.
If you like, you could say %{$mail}{$msg) instead of $mail->{$msg} as a
matter of personal taste; the arrow to dereference is more commonly
seen.
> Use at your own risk, no warranty applies. Comments on how it might
> be better written gratefully received. Feel free to pass onto people
> even less skiled at Perl but with more viruses (i.e. desparate).
>
If it works for you then it is right ;) What happens if I send you a
genuine email with an uppercase subject for some convoluted but
legitimate reason?
I don't tend to use parentheses where there is no method argument. It
could be a bit shorter because you copy values in a couple of places
but that can't matter on something this size.
If you want to be really humbled, perlmonks.org usually does the job.
- --
http://matthewb.org/public_key.txt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/bWGhy5o0lRFL2ooRAqJUAKCkfXnJUhC+/eHXDrgvSqLDBzSR6QCfRRR+
XnsrZRTjSVtw+vjqKzPmoSc=
=EzwN
-----END PGP SIGNATURE-----
More information about the Devoncornwall-pm
mailing list