[ABE.pm] perl 5.10 rules! - a switch statement

Michael C. Toren mct at toren.net
Mon Jun 4 15:32:53 PDT 2007


I have to say that I'm fairly unimpressed with "given/when", but *this*:

> In 5.10, you could have solved this problem at the outside by writing:
> 
>   die "We don't support your browser!" if $user_agent ~~ $unsupported_browser;
> 
> When you started out, you'd have put a string in there, and it would use eq.
> Later, you'd put in an arrayref, and it would check whether $user_agent was
> in the arrayref.  Finally, you'd put in a coderef and it would call it.  By
> saying that something is a "smart match" target, rather than something more
> specific, you can make your code very flexible without writing a lot of
> polymorphism on your own.

...is really cool!  I can't wait to play with it. :-)

Thanks,
-mct


More information about the ABE-pm mailing list