• Home

  • Custom Ecommerce
  • Application Development
  • Database Consulting
  • Cloud Hosting
  • Systems Integration
  • Legacy Business Systems
  • Security & Compliance
  • GIS

  • Expertise

  • About Us
  • Our Team
  • Clients
  • Blog
  • Careers

  • VisionPort

  • Contact
  • Our Blog

    Ongoing observations by End Point Dev people

    Perl’s Scalar::Util::dualvar

    Jon Jensen

    By Jon Jensen
    August 24, 2009

    I just came across this fun Perl function that I can’t think of a (good) use for, but have to share.

    In the Scalar::Util module is the function dualvar:

    dualvar NUM, STRING

    Returns a scalar that has the value NUM in a numeric context and the value STRING in a string context.

        $foo = dualvar 10, "Hello";
        $num = $foo + 2;                    # 12
        $str = $foo . " world";             # Hello world
    

    Using that in the right place could lead a future programmer down some fun debugging paths!

    perl


    Comments