> On Wed, Jul 8, 2009 at 10:16, Steve Bertrand<st...@ibctech.ca> wrote:

>> %hash = map { my $x = $_; $_ =~ s/h_/hello_/;$_, $hash{$x} } keys %hash;
> snip
>
> The following bits of advice are stylistic in nature, so you can
> ignore them, but there really are good reasons not to.
>
> As name, $x does not really mean anything in this context.  A better
> name is $k for key, especially if you use $k often to mean key.
>
> The fat comma (=>) is better than the normal comma in this case.  They
> will function the same way, but the fat comma makes it clear that
> there is a key/value pair being created.

Apparently, my webmail application (Squirrelmail) decides that it's best
to snip out credit for the most recent quote, so I apologize for that,
Chas.

Thanks for the style tips. I really do appreciate those, because who knows
who will read my code in the future.

While coding, I don't use unnamed, hard-to-understand vars such as $x. Now
I know the importance of not using such in q&d test scripts as well ;)

I'm glad that you pointed out the importance of using => when dealing with
a hash. I left out some things in the line that I wrote, mostly for
brevity, so it would fit nicely within email standard width.

However, I did not realize that I could use => in place of , wherever a
list is present (even though I know I've read over it in the Cookbook).
That is handy.

I'm so appreciative of this list, and everyone on it. I'm also
appreciative of the people who have written the books. It's clear to me
that teaching Perl is their ultimate goal.

Cheers to all of those who read this list and just 'fit in' when necessary,

Steve




>
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to