Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Perl 5.10 given/when tricks and caveats

by mr_mischief (Monsignor)
on Sep 04, 2008 at 21:08 UTC ( #709120=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    given($foo) {
        when (/x/) { say '$foo contains an x'; continue }
        when (/y/) { say '$foo contains a y' }
        default    { say '$foo contains neither an x nor a y' }
    }
    
  2. or download this
    #!/usr/local/bin/perl
    
    use feature qw{ switch };
    ...
    match 3;
    match 4;
    match 5;
    
  3. or download this
    1:
    2:
    3:
    4:
    5:
    
  4. or download this
    #include <stdio.h>
    #include <stdlib.h>
    ...
    
        exit( 0 );
    }
    
  5. or download this
    1: 4
    2:
    3:
    4:
    5:
    
  6. or download this
    #!/usr/local/bin/perl
    
    use feature qw{ switch };
    ...
    
    match 'Just another Perl hacker';
    match 'Just another Perl slacker';
    
  7. or download this
    Just another Perl hacker: Me too!
    Just another Perl slacker:
    
  8. or download this
    $foo contains an x
    $foo contains neither an x nor a y
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://709120]
Approved by moritz
Front-paged by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-08-20 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (120 votes), past polls