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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:33:36+00:00 2026-05-23T02:33:36+00:00

Perl’s bignum bigint and bigrat pragmas helpfully contain an in_effect function that will detect

  • 0

Perl’s bignum bigint and bigrat pragmas helpfully contain an in_effect function that will detect if the pragma is loaded into a scope by probing the hints hash. However, this only works in version 5.9.4 and later of perl, since that’s when the lexical hints hash was introduced.

Is there any good way of determining if these pragmas are in effect in earlier versions of perl? For my uses, I would like to support back to version 5.8.8.

Update: mob’s solution below will work if I had access to the lexical space where bignum may be in effect. However, for my use case, I am writing a function that will be called from that space, and inside that function I need to determine if the caller’s scope has bignum loaded. (ie, in my code I am calling something like bignum::in_effect(2) to look a few frames up the call stack)

 sub test_sub {is_bignum_in_effect_in_the_caller}
              # bignum::in_effect(1) in 5.9.4+

 test_sub(); # no bignum
 {use bignum; test_sub()}  # yes bignum
  • 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-23T02:33:37+00:00Added an answer on May 23, 2026 at 2:33 am

    I don’t know if this qualifies as a ‘good’ way, but you can do a simple operation and see if you are getting the bigint/bigrat result or the conventional Perl result.

    $bigint_enabled = length(1E20) == 21;   # conventional result is 5
    

    At the risk of making this answer even less good, how can you determine whether bigint is enabled in the caller’s scope?

    One. Require the caller to tell you whether bignum is enabled.

    # your package
    package Foo;
    use base 'Exporter';
    use bigint;
    our @EXPORT = qw($BIGINT_TEST multiply);
    our $BIGINT_TEST = $]>=5.009004 
        ? "bigint::in_effect()"
        : "\$bigint::VERSION<0.22 || length(1E20)==21";
    
    sub multiply {
        my ($arg1, $arg2, $bigint_enabled) = @_;
        if ($bigint_enabled) {
            use bigint;
            return $arg1*$arg2;
        } else {
            no bigint;
            return $arg1*$arg2;
        }
    }
    
    # user program
    use Foo;
    use bigint;
    print "Enabled: ", multiply(1E15,1E10, eval $BIGINT_TEST), "\n";
    {
        no bigint;
        print "Disabled: ", multiply(1E15,1E10,eval $BIGINT_TEST), "\n";
    }
    
    # result
    $ perl510 user_program.pl
    Enabled: 10000000000000000000000000
    Disabled: 1e+25
    
    $ perl587 user_program.pl      ($bignum::VERSION eq 0.07)
    Enabled: 10000000000000000000000000
    Disabled: 10000000000000000000000000
    
    $ perl588 user_program.pl      (includes upgrade to bignum 0.25)
    Enabled: 10000000000000000000000000
    Disabled: 1e+25
    

    Two. Source filtering? Hack the op tree? Use either of these methods to insert an argument to the method call or to set a global variable prior to the method call.

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

Sidebar

Related Questions

Perl has a lovely little utility called find2perl that will translate (quite faithfully) a
Perl supports three ways (that I know of) of running external programs: system :
Perl is really good for writing the kind of string/file parsing programs that I
Perl newbie here. I have a log file that I need to parse out
The Perl script that contains a Unix command to grep the ethernet NICs cannot
Perl 5.14 gives us the extended each function which operates on arrays as well
Perl (no modules loaded and -Tw & strict) I found much info on regex
Perl docs recommend this: $foo = $bar =~ s/this/that/r; However, I get this error:
Perl is complaining that it can't find a module that is right there in
perl -MCPAN -e'install File::Find::Rule' CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Database was

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.