in reply to Re^6: How to look for two different file extensions?
in thread How to look for two different file extensions?

3) Why is introducing "Perl6" in this name-dropping way to a Perl beginner a good thing?
Because Perl 6 does exactly the right thing in this case, something that we have all hoped one day that our language would do, and precisely the thing that the original poster was hoping to work:
> for 1..6 { say $_ if $_ == 2|3|5|8 } 2 3 5
which is exactly how you would say it in English: "if value equals 2 or 3 or 5 or 8", which is so much easier than: "if value equals 2 or value equals 3 or value equals 5 or value equals 8".

Replies are listed 'Best First'.
Re^8: How to look for two different file extensions?
by Anonymous Monk on Mar 09, 2017 at 23:08 UTC
    for (1..6) { print "$_\n" if $_ == 2 or $_ == 3 or $_ == 5 or $_ == 8 ; }
    Perl 5 does EXACTLY the right thing and is production ready. I have never hoped that your code would ever work in Perl5. Your simplified example is not the real world.
      Sure, I am doing that everyday at $work in Perl 5, but if I can save typing four times almost the same thing with just different values, then I am happier. it gives me more time to concentrate on the real problem I have to solve.

      And I am really sorry for you if you have already given up hope that programming languages could be easier.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re^8: How to look for two different file extensions?
by 1nickt (Canon) on Mar 10, 2017 at 00:17 UTC

    Your code is no closer to English than

    say $_ if $_ =~ /(2|3|5|8)/;
    But even if the beginner found it for some reason more like the aforementioned European language, in which, it is to be assumed in your scenario, he has great fluency, please explain again why would it be a good idea for him to learn that syntax, which doesn't work in the language he is (a) asking about and (b) hoping to use to accomplish an actual task?

    And people say I have an agenda!


    The way forward always starts with a minimal test.

      To paraphrase the old proverb: "It doesn't matter whether it's 'closer to English' if it gives the wrong answer."

      Needs ^anchors$ if these are to be == matches. :P

A reply falls below the community's threshold of quality. You may see it by logging in.