[aklug] Re: perl lists question, sorting, sort of.

From: Michael Fowler <michael@shoebox.net>
Date: Wed Aug 18 2010 - 00:11:51 AKDT

On Tue, Aug 17, 2010 at 08:06:32PM -0800, Arthur Corliss wrote:
> It should be returning a Perl equivalent of struct in_addr_t, which is an
> unsigned four byte integer in C. Odd. Probably one of those times I should
> have looked at the Perl source rather than hitting the C man page.

That is the Perl equivalent of an in_addr struct (in_addr_t is just a
typedef, and not the struct that inet_aton and inet_ntoa use).

Basically, the Perl socket functions are very thin wrappers around the C
functions. They receive an SV (scalar value) containing a string, they
pull out the (char *) pointer, and cast it to a (struct in_addr *).

> Not at all, it's part of more secure programming. Intent doesn't protect
> you from unsafe input. It's a relatively unimportant in this code, but
> overall it's a good habit to get into just to avoid unintended consequences.

Making your intent clear protects you from maintenance headaches.
Adding code to make it more "secure", when it in fact does nothing,
makes it less secure, because it's harder to understand and maintain.

Protecting against external data sources is vital. That is not the same
thing as future-proofing your code to protect against changes to the
code. That kind of "security" leads to over-design, and vestigial
pieces that confuse any subsequent work.

To be clear, /s changes the meaning of the . metacharacter; it will
match a newline. /m changes the meaning of ^ and $ to match after and
before a newline, respectively. You are not using ., ^, or $ in your
regex.

--
Michael Fowler
www.shoebox.net
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Aug 18 00:13:53 2010

This archive was generated by hypermail 2.1.8 : Wed Aug 18 2010 - 00:13:53 AKDT