Perl Programming/Keywords/given

The given keyword
given is a highly experimental flow-control keyword that is used in a similar manner like the switch keyword in C.

The given loop is supported from Perl 5.10.1 onwards. This can be used with the use feature "switch" or with the use 5.10.1 command. With the given command, the other experimental keywords break, <tt>continue</tt>, <tt>default</tt>, and <tt>when</tt> are also enabled. From Perl 5.16 onwards, it is also possible to use these keywords with the <tt>CORE::</tt> prefix and without using the <tt>use</tt> statements.

In contrast to the <tt>switch</tt> statement in C with the <tt>case</tt> parts, the <tt>given</tt> switch leaves after each <tt>when</tt> statement without needing a <tt>break</tt> keyword. If this is not desirable, the <tt>continue</tt> has to be used.