Author Topic: Perl oddities  (Read 9027 times)

0 Members and 1 Guest are viewing this topic.

Offline deadly7

  • 42
  • x86
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Perl oddities
« on: August 26, 2011, 06:28:32 pm »
Today at work I discovered Perl has an "OR" operator and the usual "||" operator. They have different precedence. In fact, "OR" is the lowest of operators.

lolwtf
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Perl oddities
« Reply #1 on: August 26, 2011, 06:39:19 pm »
fuck perl

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Perl oddities
« Reply #2 on: August 28, 2011, 04:52:07 pm »
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline deadly7

  • 42
  • x86
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Re: Perl oddities
« Reply #3 on: August 28, 2011, 05:40:34 pm »
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.
This makes more sense than "||" and "OR"
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Perl oddities
« Reply #4 on: August 28, 2011, 06:20:05 pm »
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: Perl oddities
« Reply #5 on: August 28, 2011, 06:35:27 pm »
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)


Vouching !== and === usefulness; if a function returns 0 as a valid, that's not false!  They're also fractionaly faster than their typeless alternative comparisons.
And like a fool I believed myself, and thought I was somebody else...

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: Perl oddities
« Reply #6 on: August 28, 2011, 08:59:05 pm »
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)


Vouching !== and === usefulness; if a function returns 0 as a valid, that's not false!  They're also fractionaly faster than their typeless alternative comparisons.
I love !== and ===

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Perl oddities
« Reply #7 on: August 28, 2011, 09:00:32 pm »
Yeah, you almost need something like === in a weakly-typed language.

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: Perl oddities
« Reply #8 on: August 28, 2011, 09:02:35 pm »
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Perl oddities
« Reply #9 on: August 28, 2011, 09:05:05 pm »
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: Perl oddities
« Reply #10 on: August 28, 2011, 09:14:35 pm »
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Make a class for each variable type that forces a explicit type.  :smugface:
And like a fool I believed myself, and thought I was somebody else...

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Perl oddities
« Reply #11 on: August 28, 2011, 09:29:35 pm »
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Make a class for each variable type that forces a explicit type.  :smugface:

Heh, but that doesn't prevent compile errors when you pass one type into a method expecting another type. Just so many problems. You can avoid them pretty well with a dose of convention and care, but it's just so much easier in a language like Java.

Don't get me wrong -- there are things that I'd never choose to do in Java. There are just a couple of things that creep me out about Ruby.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Perl oddities
« Reply #12 on: August 29, 2011, 01:24:54 am »
php also has === and !==. They're actually really useful. :)
I agree.  We actually just standardized using these operators on my team at work unless there's a really good reason not to.

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)
Yeah, it coerces the value into a true Boolean (something about the phrase "true Boolean" is making me laugh).  Also fun is its counterpart, !!!.  :)  (There's actually no reason for !!!, since a single ! will coerce the value into the true Boolean value opposite of the meaning of the original).
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Perl oddities
« Reply #13 on: August 29, 2011, 09:54:11 am »
I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)
Yeah, it coerces the value into a true Boolean (something about the phrase "true Boolean" is making me laugh).  Also fun is its counterpart, !!!.  :)  (There's actually no reason for !!!, since a single ! will coerce the value into the true Boolean value opposite of the meaning of the original).
!! and !!! and !!!! and etc seem more like conventions than actual operators, since they're just abusing the functionality that ! provides. :)

I hadn't really thought of using those before, though, it's kinda neat. And I imagine fairly language agnostic, unless some stupid language uses ! for a bitwise negate instead of logical. But they're stupid. :)