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 281289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:11:26+00:00 2026-05-12T05:11:26+00:00

This is strange. The following: $sum = !0; print $sum; prints out 1 as

  • 0

This is strange.
The following:

$sum = !0;
print $sum;

prints out 1 as you would expect. But this

$sum = !1;
print $sum;

prints out nothing. Why?

  • 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-12T05:11:26+00:00Added an answer on May 12, 2026 at 5:11 am

    Be careful: what you’ve written isn’t doing what you think it’s doing. Remember, perl has no real boolean datatype. It’s got scalars, hashes, lists, and references. The way it handles true/false values, then, is contextual. Everything evaluates to “true” in perl except for undefined variables, the empty list, the empty string, and the number 0.

    What your code is doing, then, is taking the inverse of a value that evaluates to “false”, which can be anything which is not in the list above. By convention and for simplicity’s sake, perl returns 1 (though you should not rely on that; it could very well return a list containing a series of random numbers, because that will evaluate to “true” as well.)

    A similar thing happens when you ask for the inverse of a value that evaluates to “true.” What’s actually being printed out is not “nothing,” it’s the empty string (”), which, as I mentioned, evaluates to “false” in boolean expressions. You can check this:

    print "This evaluates to false\n" if( (!1) eq '');
    

    If you’re asking for why perl spits out the empty string instead of one of the other “false” values, well, it’s probably because perl is made to handle strings and that’s a perfectly reasonable string to hand back.

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

Sidebar

Related Questions

In the following code, this line is a bit strange to me: var x=document.forms[myForm][fname].value;
I have the following query, now the strange thing is if I run this
I have this strange problem in my unit tests. See the following code _pos
I got this strange issue following is the code snippet which is working properly.
I am facing this strange problem with the following section of code <% if
I'm having this strange issue with my ItemsControl grouping. I have the following setup:
I've been having this strange problem with apply lately. Consider the following example: set.seed(42)
I am struck in this strange problem . I am using the following method
I found this strange behaviour not only when debugging but also during normal execution
I just prepare small update for my android app, but I get this strange

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.