Necessary import library.
Initialize the variable and play ($val).#!/usr/bin/perl
use strict;
use warnings;
use Switch;
my $val = 'a'; switch ($val) { case 1 { print "number 1" } case "a" { print "string a" } case [1..10,42] { print "number in list" } case /\w+/ { print "pattern" } case qr/\w+/ { print "pattern" } else { print "previous case not true" }
}
0 comentários:
Post a Comment