[Melbourne-pm] given/when

Mathew Robertson mathew.blair.robertson at gmail.com
Mon Oct 29 18:49:22 PDT 2012


Hi list,

What is the expected output of this:

use strict;
use v5.14;
sub true { 1 }
sub false { 0 }
my $x = 0;
given ($x) {
  when (true) { print "true".$/; }
  when (false) { print "false".$/; }
  default { print "unknown".$/; }
}

or:

sub M { 'M' }
sub N { 'N' }
my $x = "N";
given ($x) {
  when (M) { print "m".$/; }
  when (N) { print "n".$/; }
  default { print "unknown".$/; }
}


cheers,
Mathew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20121030/8b9cde4c/attachment.html>


More information about the Melbourne-pm mailing list