Here a sample with given/take using strings:
use strict; use warnings; use feature qw(switch); my $name = "Monday"; given ($name) { when ("Sunday") { print "first\n"} when ("Monday") { print "second\n"} when ("Tuesday") { print "third\n"} default { print "None\n" } } print "Bye\n";the "use feature qw(switch)" line tell the compiler to use Perl6's given/when switch feature
No comments:
Post a Comment