in reply to Smart-search/When question

Perl perlsyn

"Another useful shortcut is that, if you use a literal array or hash as the argument to given , it is turned into a reference. So given(@foo) is the same as given(\@foo) , for example."

Therefore, just use an array reference like already suggested by toolic:

when ([qw(jpeg jpg png)]) {

Or use a regex

when (/^(?:jpeg|jpg|png)$/) {