Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:54:12+00:00 2026-05-27T09:54:12+00:00

Why does // have lower precedence than == in (at least) perl 5.010? For

  • 0

Why does // have lower precedence than == in (at least) perl 5.010?

For example, this

use 5.010;
my $may_be_undefined = 1;
my $is_equal_to_two = ($may_be_undefined//0 == 2);
say $is_equal_to_two;

prints (for me) very unexpected result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:54:12+00:00Added an answer on May 27, 2026 at 9:54 am

    It’s because of the category of operators which // falls under, aswell as ==.

    == is an “equality operator” though // falls under the category of “C-style logical operators“.

    As an example; && is in the same “category” as //, with that said both of the statements below are equivalent when it comes to operator precedence. That might make it easier to understand?

      print "hello world" if $may_be_undefined && 0 == 2;
      print "hello world" if $may_be_undefined // 0 == 2;
    

    Documentation of C-style Logical Defined-Or ( // )

    Although it has no direct equivalent in C, Perl’s // operator is related to its C-style or. In fact, it’s exactly the same as ||, except that it tests the left hand side’s definedness instead of its truth.

    Thus, $a // $b is similar to defined($a) || $b (except that it returns the value of $a rather than the value of defined($a)) and yields the same result as defined($a) ? $a : $b (except that the ternary-operator form can be used as a lvalue, while $a // $b cannot).

    This is very useful for providing default values for variables. If you actually want to test if at least one of $a and $b is defined, use defined($a // $b) .

    The ||, // and && operators return the last value evaluated (unlike C’s || and &&, which return 0 or 1).


    Documentation of Operator Precedence and Associativity

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does ** have any special meaning in C? Like this: static intparse_one (int argc,
Does * have a special meaning in Python as it does in C? I
i have a table (System.Web.UI.WebControls). each row does have three cells. in cells' controls
Both are mathematical values, however the float does have more precision. Is that the
Using C# .NET 2.0, I have a composite data class that does have the
what is the best way to change the toolbars in Zimbra. Zimbra does have
Does anyone have any recommendations of tools that can be of assistance with moving
Does C# have built-in support for parsing strings of page numbers? By page numbers,
Does anyone have a definitive answer to whether Sql Server Management Objects is compatible
Does anyone have the secret formula to resizing transparent images (mainly GIFs) without ANY

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.