On Tue, 2002-04-23 at 10:30, Chas Owens wrote: > On Mon, 2002-04-22 at 06:52, walter valenti wrote: > > Hi, > > > > there is in Perl a statement "case" like in "C" or in "Pascal" ??? > > > > Walter > > Damian Conway has written a module to implement a switch for Perl as a > proof of concept for Perl 6. You can install it by saying > > perl -MCPAN -e "install Switch" > > <snip href="perldoc Switch"> > use Switch; > > switch ($val) { > > case 1 { print "number 1" } > case "a" { print "string a" } > case [1..10,42] { print "number in list" } > case (@array) { print "number in list" } > case /\w+/ { print "pattern" } > case qr/\w+/ { print "pattern" } > case (%hash) { print "entry in hash" } > case (\%hash) { print "entry in hash" } > case (\&sub) { print "arg to subroutine" } > else { print "previous case not true" } > } > </snip> <snip reason='sig' />
Sorry, this email got sent before I was finished with it. The switch statement Damian has created in this module is very close to -- but is not -- the switch statement that will be implemented in Perl 6. For one thing Perl 6 will use given/when/default instead of switch/case/else. If you use this module make certain to read the docs that will come with Perl 6 to insure you know all of the differences. -- Today is Pungenday the 40th day of Discord in the YOLD 3168 Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]