in reply to Regex Mystery

... # FAILS $file = 'C:\tmp'; $regex = qr~C:\\tmp~; if ($file =~ m/$regex/i) { print "\nTest with backslashes -- If stmt is true...\n"; }

Prints...

Test with forward slashes -- If stmt is true... Test with backslashes -- If stmt is true...

FYI coding while tired is a recipe for adding errors to code that you will find hard to find later.

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^2: Regex Mystery
by choroba (Cardinal) on Apr 13, 2025 at 17:54 UTC
    > FYI coding while tired is a recipe for adding errors to code that you will find hard to find later.

    But sometimes, coding while tired delivers at least something before the deadline. Life is hard.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      There are various benefits of coding before sleep
      • you get started
      • you keep your sleeping brain busy with non social stuff
      • you may wake up with a solution
      • you may not contribute to the gene pool of the human race

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        Ha ha ha ha! Now that's funny! :)

        "It's not how hard you work, it's how much you get done."

      But sometimes, coding while tired delivers at least something before the deadline.

      Yes, it does. Mostly the privilege of fielding support calls all weekend long, therefore pissing off the significant other. And the option to watch your favourite movies all night long, since you're gonna sleep on the couch anyway...

      PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
      Also check out my sisters artwork and my weekly webcomics
Re^2: Regex Mystery
by roho (Bishop) on Apr 13, 2025 at 17:14 UTC
    Thanks InfiniteSilence. You're right, working when tired produces diminishing returns.

    "It's not how hard you work, it's how much you get done."

      In my case, that would be negative returns.

      When i'm tired, i'm basically more productive doing nothing than when i'm touching code.

      Also, for a few hours after i'm forced by my body to take my pain meds for bad back (usually once a month on average). And being on the autistic spectrum, there are sometimes days my brain just refuses to do anything productive and i just can't concentrate on one singel thing for more than a minute or so.