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

  • Home
  • SEARCH
  • 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 8881879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:26:19+00:00 2026-06-14T20:26:19+00:00

The Perl defined function (and many others) returns a Boolean value. Given Perl doesn’t

  • 0

The Perl defined function (and many others) returns “a Boolean value”.

Given Perl doesn’t actually have a Boolean type (and uses values like 1 for true, and 0 or undef for false) does the Perl language specify exactly what is returned for a Boolean values? For example, would defined(undef) return 0 or undef, and is it subject to change?

  • 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-06-14T20:26:20+00:00Added an answer on June 14, 2026 at 8:26 pm

    In almost all cases (i.e. unless there’s a reason to do otherwise), Perl returns one of two statically allocated scalars: &PL_sv_yes (for true) and &PL_sv_no (for false). This is them in detail:

    >perl -MDevel::Peek -e"Dump 1==1"
    SV = PVNV(0x749be4) at 0x3180b8
      REFCNT = 2147483644
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 1
      NV = 1
      PV = 0x742dfc "1"\0
      CUR = 1
      LEN = 12
    
    >perl -MDevel::Peek -e"Dump 1==0"
    SV = PVNV(0x7e9bcc) at 0x4980a8
      REFCNT = 2147483647
      FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
      IV = 0
      NV = 0
      PV = 0x7e3f0c ""\0
      CUR = 0
      LEN = 12
    

    yes is a triple var (IOK, NOK and POK). It contains a signed integer (IV) equal to 1, a floating point number (NV) equal to 1, and a string (PV) equal to 1.

    no is also a triple var (IOK, NOK and POK). It contains a signed integer (IV) equal to 0, a floating point number (NV) equal to 0, and an empty string (PV). This means it stringifies to the empty string, and it numifies to 0. It is neither equivalent to an empty string

    >perl -wE"say 0+(1==0);"
    0
    
    >perl -wE"say 0+'';"
    Argument "" isn't numeric in addition (+) at -e line 1.
    0
    

    nor to 0

    >perl -wE"say ''.(1==0);"
    
    
    >perl -wE"say ''.0;"
    0
    

    There’s no guarantee that this will always remain the case. And there’s no reason to rely on this. If you need specific values, you can use something like

    my $formatted = $result ? '1' : '0';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When building a Perl module ExtUtils::MakeMaker uses the flags defined in Config.pm (see perldoc
My Perl Script retrieves the argument in the below way. Have Getoptions function to
Possible Duplicate: In Perl, how can I check from which module a given function
I have a function in C++ such as: void* getField(interface* p) { int* temp
Before I begin: I have spent a long time on many forums (including Stack
I use this scrub function to clean up output from other functions. #!/usr/bin/perl use
I'm running into a little trouble with Perl's built-in split function. I'm creating a
I have a Perl program that has a GTK2 GUI (via the Gtk2 package).
I just started on learning perl, and in the sample code given by my
How to test if a capture is defined in Perl regexp matching? #!/usr/bin/env perl

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.