Switch::Perlish

A Perlish implementation of the switch statement
Download

Switch::Perlish Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dan Brook
  • Publisher web site:
  • http://search.cpan.org/~broq/

Switch::Perlish Tags


Switch::Perlish Description

A Perlish implementation of the switch statement Switch::Perlish is a Perl-oriented implementation of the switch statement. It uses smart-matching in cases which can be configured and extended by the user. There is no magical syntax so switch/case/default expect coderefs, which are most simply provided by anonymous subroutines. By default successful case statements do not fall through. To fall through a case block call the fallthrough subroutine explicitly. For C style switch behaviour simply call the module with an upper-case C i.e use Switch::Perlish 'C'; To 'fall through' in a C< case > block means that the C< switch > block isn't exited upon success. upon a C< case > succesfully matching all subsequent C< case >s succeed; to break out from the current C< switch > completely use C< stop >.SYNOPSIS use Switch::Perlish; switch $var, sub { case 'foo', sub { print "$var is equal to 'foo'\n" }; case 42, sub { print "$var is equal to 42\n"; fallthrough }; case , sub { print "$var found in list\n" }; case { foo => 'bar' }, sub { print "$var key found in hash\n" }; case \&func, sub { print "$var as arg to func() returned true\n" }; case $obj, sub { print "$var is method in $obj and returned true\n" }; case qr/\bfoo\b/, sub { print "$var matched against foo\n" }; default sub { print "$var did not find a match\n" }; }; Requirements: · Perl


Switch::Perlish Related Software