views:

283

answers:

6

Hi!

I didn't realize until recently that Perl 5.10 had significant new features and I was wondering if anyone could give me some good resources for learning about those. I searched for them on Google and all I found was some slides and a quick overview. Some of the features (to me at least) would be nice if they had more explanation.

Any links would be appreciated.

-fREW

+14  A: 

The perldelta manpage has all the nitty-gritty details. There's a brief (but informative) slide presentation, Perl 5.10 for people who aren't totally insane. And a good PerlMonks discussion on the issue.

friedo
yeah, those are the two things that I found in my google search. I guess perldelta is the best resource for all that then.
Frew
I like the "Perl 5.10 for people who aren't totally insane". Nice concise overview.
Axeman
+14  A: 

I found this article useful.

This one is more focused on 5.10 Advanced Regular Expressions.

And also A beginners' Introduction to Perl 5.10.

Finally, this excellent summary on why you should start using Perl 5.10 and from which I extracted the following:

  • state variables No more scoping variables with an outer curly block, or the naughty my $f if 0 trick (the latter is now a syntax error).
  • defined-or No more $x = defined $y ? $y : $z, you may write $x = $y // $z instead.
  • regexp improvements Lots of work done by dave_the_m to clean up the internals, which paved the way for demerphq to add all sorts of new cool stuff.
  • smaller variable footprints Nicholas Clark worked on the implementations of SVs, AVs, HVs and other data structures to reduce their size to a point that happens to hit a sweet spot on 32-bit architectures
  • smaller constant sub footprints Nicholas Clark reduced the size of constant subs (like use constant FOO => 2). The result when loading a module like POSIX is significant.
  • stacked filetests you can now say if (-e -f -x $file). Perl 6 was supposed to allow this, but they moved in a different direction. Oh well.
  • lexical $_ allows you to nest $_ (without using local).
  • _ prototype you can now declare a sub with prototype . If called with no arguments, gets fed with $ (allows you to replace builtins more cleanly).
  • x operator on a list you can now say my @arr = qw(x y z) x 4. (Update: this feature was backported to the 5.8 codebase after having been implemented in blead, which is how Somni notices that it is available in 5.8.8).
  • switch a true switch/given construct, inspired by Perl 6
  • smart match operator (~~) to go with the switch
  • closure improvements dave_the_m thoroughly revamped the closure handling code to fix a number of buggy behaviours and memory leaks.
  • faster Unicode lc, uc and /i are faster on Unicode strings. Improvements to the UTF-8 cache.
  • improved sorts inplace sorts performed when possible, rather than using a temporary. Sort functions can be called recursively: you can sort a tree
  • map in void context is no longer evil. Only morally.
  • less opcodes used in the creation of anonymous lists and hashes. Faster pussycat!
  • tainting improvements More things that could be tainted are marked as such (such as sprintf formats)
  • $# and $* removed Less action at a distance
  • perlcc and JPL removed These things were just bug magnets, and no-one cared enough about them.
David Segonds
heh, you beat me to it! I wrote that article :)
dland
And this is indeed a good article. I made sure to leave a pointer to your original work. I did not want people to think I wrote that.
David Segonds
+4  A: 

Regex Improvements include named captures: Look Here

Bash
+13  A: 

There's been a string of articles in Perl Tips about Perl 5.10:

There are also my What's new in Perl 5.10 slides on Perl Training Australia's presentations page, but since they were written before 5.10 was released, some things may have changed slightly. I believe that rjbs' Perl 5.10 for people who aren't totally insane now covers everything my slides used to.

All the best,

Paul

Mandatory bias disclosure: I wrote almost all of the resources mentioned in this post,

pjf
pjf is just too modest. His article on the [smart match operator](http://perltraining.com.au/tips/2008-04-18.html) is simply the best I've seen on the subject. He's my hero.
bart
+3  A: 

See Ricardo Signes' slides for his excellent "Perl 5.10 For People Who Aren't Totally Insane."

http://www.slideshare.net/rjbs/perl-510-for-people-who-arent-totally-insane

Andy Lester
+6  A: 

I just updated Learning Perl, Fifth Edition to cover 5.10. Other than that, the resources that other people mentioned, including perldelta, are pretty good. I've written a couple of articles about some of the features for The Perl Review.

The best way to get started is to pick an interesting feature and play around with it. That's how the authors of the guides you'll find figured it out. That's how you really should start learning anything is just about any language.

If you have a question about using a particular feature, ask that. :)

brian d foy