I think this is a bug:

tes...@krauzer:~/Perl/Ex/ch15$ cat when

#!/usr/bin/perl -w

use 5.010;

use strict;



given($ARGV[0]) {

    when(/fred/i) { say 'Name has fred in it'; continue }

    when(/^Fred/) { say 'Name starts with Fred'; continue }

    when('Fred')  { say 'Name is Fred' }

    default          { say "I don't see a Fred" }

}

tes...@krauzer:~/Perl/Ex/ch15$ ./when Fred

Name has fred in it

Name starts with Fred

Name is Fred

tes...@krauzer:~/Perl/Ex/ch15$ ./when Frederick

Name has fred in it

Name starts with Fred

I don't see a Fred

tes...@krauzer:~/Perl/Ex/ch15$

As you can see, the 'default' was not supposed to say anything in the second 
time the program is run, with the argument "Frederick"..
The last 'when' is supposed to have a hidden "break", right? So what's wrong? 





--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to