Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Given When Syntax

by LanX (Archbishop)
on Mar 15, 2014 at 19:56 UTC ( #1078481=note: print w/replies, xml ) Need Help??


in reply to Re: Given When Syntax
in thread Given When Syntax

> use the dark arts mate

maybe a misunderstanding, but I thought black is supposed to be beautiful not ugly! :-b

sub switch ($$); for my $var (1..4) { my $i; switch $var => { 1 => sub { $i = "One"}, 2 => sub { $i = "Two"}, 3 => sub { $i = "Three"}, '' => sub { $i = "Other"}, }; print "$var is $i\n"; } sub switch ($$) { my ($case, $href) =@_; if ( exists $href->{$case} ) { $href->{$case}->(); } else { $href->{''}->(); } }

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^3: Given When Syntax
by Lennotoecom (Pilgrim) on Mar 15, 2014 at 20:05 UTC
    symbolic references = dark arts no?
      > symbolic references = dark arts no?

      I'm not questioning the "dark" just the "art" in your statement. ;)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        art is subjective :P

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-12-10 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (50 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!