in reply to Smart-search/When question

Because qw// constructs a list not an array.

When you did this:

given ($ext) { when (qw/jpeg jpg png/) {

You should have seen the warning:

Useless use of a constant in void context at

You could do it in-line as:

given ($ext) { when ( @{[ qw/jpeg jpg png/] ]} ) {

But it's a bit cheesy.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Smart-search/When question
by John M. Dlugosz (Monsignor) on Mar 18, 2011 at 07:46 UTC
    What's the difference between a list and an array, as far as when is concerned? What's an example of a list used here that is different from the meaning of an array with the same elements?
      What's the difference between a list and an array, as far as when is concerned?

      This is one of the ways that given/when break expectations in that in most cases, the use of an array expression @a generates a list.

      The only other exception to this I can think of is a subroutine with a prototype of (\@) which causes a reference to the array to be passed to the subroutine. I think that's what is happening here, though the documentation leave much to be desired.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.