Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: How to look for two different file extensions?

by davies (Parson)
on Mar 09, 2017 at 19:49 UTC ( #1184083=note: print w/replies, xml ) Need Help??


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

  • It introduces TIMTOWTDI, which I don't see elsewhere in this thread.
  • It introduces at least 2 regex concepts, anchoring and alternation, which the OP or others might find this post helpful in explaining.
  • It introduces Damianware. If you haven't attended his talk (from memory) "Temporally quaquaversial virtual nanomachine programming in multiple topologically connected quantum-relativistic parallel spacetimes ... made easy", you might look out for the next time he's in your part of the world & ask him to address your PM group. I'm as certain as I can be from memory that he discussed Quantum::Superpositions in the talk, from which I learned a lot.
  • It introduces Perl6, in a way in which I thought even you would find acceptable.
If your quibble is that the line #use Perl6::Junction qw/ all any none one /; could be shortened to exclude all, none and one, I think it's a very minor point, especially given that it's a comment anyway.

Regards,

John Davies

Replies are listed 'Best First'.
Re^6: How to look for two different file extensions?
by 1nickt (Monsignor) on Mar 09, 2017 at 20:30 UTC

    1) The OP is obviously a beginner and just wanted a straight answer, which he got from ++stevieb.

    There is *always* more than one way to do it. That doesn't mean every post should contain all of them. In particular throwing out a regexp with non-basic syntax but no explanation doesn't seem like it will make things clearer for the novice.

    2) Damian Conway is just a caricature of what I'm talking about. Fun for geeks: unhelpful for Perl beginners.

    3) Why is introducing "Perl6" in this name-dropping way to a Perl beginner a good thing? For comparison, let me use the same sentence, but showing off instead my knowledge of *my* favorite hobby language:

    Blorgle supports Frobnicating, but note that Blorgle is a related but different language that I wouldn't call production ready yet.

    Would you say that is helpful to the OP or others?


    The way forward always starts with a minimal test.
      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".
        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.

        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.

        "... which is exactly how you would say it in English ..."

        Oh silly me! This whole time I thought I was trying to say it in Perl. You know ... A PROGRAMMING LANGUAGE. Something that compiles, not rhetorcizes. xD

      There is *always* more than one way to do it. That doesn't mean every post should contain all of them. In particular throwing out a regexp with non-basic syntax but no explanation doesn't seem like it will make things clearer for the novice.

      There are regexes in the OP's code, and regexes are a pretty core part of "thinking perl", so i think /AN/ answer including regex would be useful. But at the same time, how helpful is it to complain about someone elses answer like that? Why not just make a post with an explanation? Anyway.

      So heres an explanation:

      $FileExt =~/ # "file extension matches ...." \A # the start of the variable \. # match a literal dot (?: # begin a set of options foo # the option itself | # OR bar # another option ) # end of option group \z # end of variable /x; # end of pattern, enable comments in the r +egex
      ---
      $world=~s/war/peace/g

Re^6: How to look for two different file extensions?
by Anonymous Monk on Mar 09, 2017 at 20:26 UTC
    "It introduces Perl6, in a way in which I thought even you would find acceptable."

    Are you kidding? A not ready for production language that uses radically different syntax from the already production ready Perl5? Just to look clever? No thanks. Quantum::Superpositions is code for theorists, not practitioners.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1184083]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2018-07-16 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (333 votes). Check out past polls.

    Notices?