From perl.abe at rjbs.manxome.org Mon May 3 14:11:52 2010 From: perl.abe at rjbs.manxome.org (Ricardo Signes) Date: Mon, 3 May 2010 17:11:52 -0400 Subject: [ABE.pm] see you wednesday Message-ID: <20100503211152.GA9691@cancer.codesimply.com> Next week, McGrady's, Wednesday, May 12, 18:00 or so! If you're gonna be early, let me know and I will join you. -- rjbs From fiedlert at gmail.com Mon May 3 14:17:14 2010 From: fiedlert at gmail.com (Ted Fiedler) Date: Mon, 3 May 2010 17:17:14 -0400 Subject: [ABE.pm] Fwd: see you wednesday In-Reply-To: <20100503211152.GA9691@cancer.codesimply.com> References: <20100503211152.GA9691@cancer.codesimply.com> Message-ID: I can make it for 5 or 5:30. See you then. ---------- Forwarded message ---------- From: Ricardo Signes Date: Mon, 3 May 2010 17:11:52 -0400 Subject: [ABE.pm] see you wednesday To: abe-pm at pm.org Next week, McGrady's, Wednesday, May 12, 18:00 or so! If you're gonna be early, let me know and I will join you. -- rjbs _______________________________________________ ABE-pm mailing list ABE-pm at pm.org http://mail.pm.org/mailman/listinfo/abe-pm -- Sent from my mobile device Everything was beautiful and nothing hurt. -- Kurt Vonnegut From perl.abe at rjbs.manxome.org Tue May 4 07:45:39 2010 From: perl.abe at rjbs.manxome.org (Ricardo Signes) Date: Tue, 4 May 2010 10:45:39 -0400 Subject: [ABE.pm] perl 5.12! - the little things Message-ID: <20100504144539.GA10830@cancer.codesimply.com> Perl 5.12 has been out for about a month. Later this summer, I'll be giving a talk at YAPC about what's new in it, so it's time for me to draft my explanations. You get to tell me whether they make any sense or not! I'll start with some of the very small, but nice, changes. First off, you should be more likely, now, to use strict. Why? Because this: use 5.12.0; Means "die unless I'm on perl 5.12.0 or later" just like it always has, and "turn on all incompat language features introduced in 5.12" just like it meant in 5.10, but now it also means "and turn on strict." Since you'll be writing "use 5.12.0" anyway to get things like "say" and Unicode fixes, now you get strictures without any stupid boilerplate. === A few versions ago, `man` started to try to be really clever. It converts quotes into smart quotes and hyphens into endashes. This is really annoying, and breaks code samples. You try to copy a code example from man into your editor, and perl barfs because ?> is not ->. You know how much time I've lost to this? A lot. The error we got before was okay: ~$ perl5.10.1 -MCGI -e'my $q = CGI?>new;' Unrecognized character \xE2 in column 12 at -e line 1. Now it's even better: ~$ perl -MCGI -e'my $q = CGI?>new;' Unrecognized character \xE2; marked by <-- HERE after y $q = CGI<-- HERE near column 12 at -e line 1. This is one of those stupid places where a small improvement to an error message can save us a pile of time. Looking at the error message it's obvious what we did: after the CGI there's going to be some bizarre character, and we can just go look at what it is. No column counting needed. === Finally, my favorite. Maybe I shouldn't admit that this is my favorite change in 5.12, but it is. One of my favorite changes in 5.10 was the // operator, because I could write: my $x = $given // default; instead of my $x = defined $given ? $given : default; This change is similar: length($x) now returns undef if $x is undef. It used to return 0, but it would *also* warn that you'd called length on undef. This led to a LOT of code like this: if (defined $str and length $str) { ... } The new change is brilliant. Not only can we just check (length $str) in boolean context (because undef is as false as 0) but we still get that warning if we do the actually problematic thing and use the length of undef as a number, later. my $total = $length + length($x); # warns if $x is undef That's it! Tomorrow or so I'll mumble about some other cool changes. -- rjbs From waltman at pobox.com Tue May 4 08:00:42 2010 From: waltman at pobox.com (Walt Mankowski) Date: Tue, 4 May 2010 11:00:42 -0400 Subject: [ABE.pm] perl 5.12! - the little things In-Reply-To: <20100504144539.GA10830@cancer.codesimply.com> References: <20100504144539.GA10830@cancer.codesimply.com> Message-ID: <20100504150042.GH1617@mawode.com> On Tue, May 04, 2010 at 10:45:39AM -0400, Ricardo Signes wrote: > First off, you should be more likely, now, to use strict. Why? Because this: > > use 5.12.0; > > Means "die unless I'm on perl 5.12.0 or later" just like it always has, and > "turn on all incompat language features introduced in 5.12" just like it meant > in 5.10, but now it also means "and turn on strict." > > Since you'll be writing "use 5.12.0" anyway to get things like "say" and > Unicode fixes, now you get strictures without any stupid boilerplate. In 5.10 I thought you had to say use feature ':5.10'; to get all the shiny new 5.10 features. That syntax is just odd enough that I can never remember it. Could I have been saying use 5.10.0; all along? Walt From perl.abe at rjbs.manxome.org Tue May 4 08:06:55 2010 From: perl.abe at rjbs.manxome.org (Ricardo Signes) Date: Tue, 4 May 2010 11:06:55 -0400 Subject: [ABE.pm] perl 5.12! - the little things In-Reply-To: <20100504150042.GH1617@mawode.com> References: <20100504144539.GA10830@cancer.codesimply.com> <20100504150042.GH1617@mawode.com> Message-ID: <20100504150655.GB13194@cancer.codesimply.com> * Walt Mankowski [2010-05-04T11:00:42] > In 5.10 I thought you had to say > > use feature ':5.10'; > > to get all the shiny new 5.10 features. That syntax is just odd > enough that I can never remember it. Could I have been saying > > use 5.10.0; Yes. Requesting a specific version with 'use' implies requesting all the features in its bundle. -- rjbs From waltman at pobox.com Tue May 4 08:15:27 2010 From: waltman at pobox.com (Walt Mankowski) Date: Tue, 4 May 2010 11:15:27 -0400 Subject: [ABE.pm] perl 5.12! - the little things In-Reply-To: <20100504150655.GB13194@cancer.codesimply.com> References: <20100504144539.GA10830@cancer.codesimply.com> <20100504150042.GH1617@mawode.com> <20100504150655.GB13194@cancer.codesimply.com> Message-ID: <20100504151527.GJ1617@mawode.com> On Tue, May 04, 2010 at 11:06:55AM -0400, Ricardo Signes wrote: > * Walt Mankowski [2010-05-04T11:00:42] > > In 5.10 I thought you had to say > > > > use feature ':5.10'; > > > > to get all the shiny new 5.10 features. That syntax is just odd > > enough that I can never remember it. Could I have been saying > > > > use 5.10.0; > > Yes. Requesting a specific version with 'use' implies requesting all the > features in its bundle. Huh. And it's even there at the bottom of the pod for "feature". Learn something new everyday, I guess. Thanks! Walt From perl.abe at rjbs.manxome.org Sat May 15 12:09:53 2010 From: perl.abe at rjbs.manxome.org (Ricardo Signes) Date: Sat, 15 May 2010 15:09:53 -0400 Subject: [ABE.pm] perl 5.12! - container improvements Message-ID: <20100515190953.GA17091@cancer.codesimply.com> Containers! You know! Containers! Like arrays and hashes. They're kinda better now. One significant change is the availability of "each" for arrays. For hashes, each looks like this: while (my ($k, $v) = each %hash) { ... } Now you can write this: while (my ($i, $v) = each @array) { ... } This is part blessing and part curse. The behavior of "each" is sort of weird, in that the iterator is tied to the variable. If you nest "eaches," you get screwed. Still, if everybody limits use of each to simple blocks, this can be a nice little time-saver. The alternative, by the way, is: for my $i (0 .. $#array) { my $v = $array[$i]; ...; } ========= On a somewhat more esoteric note, you can now locally delete hash entries. "What??" you ask? Well, it's actually really really simple. You won't need it often, but when you do, it is great. The "local" keyword can be used to change a global variable in dynamic scope. Dynamic scope just means "until the current block of code ends." That means that if you call another routine, the local value stays in place. Not everybody knows that you can use local on private (lexically-scoped) hashes, to localize a key value. { my %h = (a => 1, b => 2); { local $h{a} = 10; say "a is $h{a}"; } say "a is $h{a}"; } This will print: a is 10 a is 1 Now, you can delete things locally: { my %h = (a => 1, b => 2); { delete local $h{a}; say "a is $h{a}"; } say "a is $h{a}"; } ...and get: Use of uninitialized value $h{"a"} in concatenation (.) or string at - line 7. a is a is 1 Again, this is one of those things you won't use every day, but it can save you a lot of time and line noise. Before, if you wanted to say "pass this hash to another routine, just as it is, but without the 'debug' entry" you had to make a copy or do bookkeeping: # Possibly expensive for very large hashes: my $result = do { my $copy = { %$orig }; delete $copy->{debug}; routine($copy); }; # OR: # Horrible. my $result = do { my $existed = exists $orig->{debug}; my $value = delete $orig->{debug}; my $result = routine($orig); $orig->{debug} = $value if $existed; }; Now, instead, you can just write: my $result = do { delete local $orig->{debug}; routine($copy); }; ========= Finally, one change for the better that doesn't actually get you anything but more warnings! Assigning to $[ now generates a warning. Why? Because it is a horrible thing to do, and nobody should ever do it or speak of it again, except to curse its name. Do you remember what it does? my @array = qw(a b c d e f); say "element 1 is $array[1]"; $[ = 1; say "element 1 is $array[1]"; This will print: element 1 is b element 1 is a So, right. Changing $[ changes the starting index value of an array. It is pretty much always a horrible idea. Now that it's been deprecated, it can go away in a future version -- or at the very least continue to remind people, via warning, that it's just utterly awful. -- rjbs From perl.abe at rjbs.manxome.org Fri May 21 12:41:15 2010 From: perl.abe at rjbs.manxome.org (Ricardo Signes) Date: Fri, 21 May 2010 15:41:15 -0400 Subject: [ABE.pm] [marsee@oreilly.com: UG News: *Free to Choose* Ebook Deal of the Day. Any O'Reilly ebook. Only $9.99.] Message-ID: <20100521194115.GA9176@cancer.codesimply.com> This is a pretty sweet deal. Almost any ebook from O'Reilly for $10. I bought two. Good for today only. ----- Forwarded message from Marsee Henon ----- *** Free to Choose *** Ebook Deal of the Day - Only $9.99 Our Ebook Deal of the Day is so popular, we want to make sure you know about it, and give you the chance to choose. Download in 4 DRM-free formats: PDF, .epub for iPad and iPhone, Kindle-compatible .mobi, and Android .apk. Only $9.99. Choose any O'Reilly ebook from our list of over 2,000 titles. (Microsoft Press titles are excluded from this offer.) Enter code "FAVFA" in the O'Reilly cart. One Day Only: 5/21/2010