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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:45:44+00:00 2026-05-11T03:45:44+00:00

I have perl, v5.6.1 built for MSWin32-x86-multi-thread Binary build 638 provided by ActiveState. I

  • 0

I have perl, v5.6.1 built for MSWin32-x86-multi-thread Binary build 638 provided by ActiveState.

I am working on a Perl script where I have declared constants that are used later for comparison purposes. For some reason, I am getting an error that states something along the line of Constant name has invalid characters at script’s line 31 (The line right after the use constant clause in the code below). I checked and found out that ‘_’ (underscores) in Constant name is a legit character. I also tried to change ‘0.00’ to just ‘0’ to see if that was the cause but I got the same error. I am not sure what I am doing wrong. Anyone know why the compiler does not like this?

Thanks!

Here is the Code:

use constant { MIN_NET_DLR => 0.00, MAX_NET_DLR => 99.99, MIN_SUM_DLR => 0.00, MAX_SUM_DLR => 999.99, MIN_UNITS => 0, MAX_UNITS => 99, MIN_SUM_UNITS => 0, MAX_SUM_UNITS => 999, PCT_THRES_AO => 1, PCT_THRES_TRANS_CUST_BI => 20, PCT_THRES_CUST => 3, }; 

PROBLEM:

The problem is that the version of constant provided by perl 5.6.1 does not support hash reference.

SOLUTION:

Use the regular declaration for constants. Hence, the declaration will look as follows:

use constant MIN_NET_DLR => 0.00; use constant MAX_NET_DLR => 99.99; use constant MIN_SUM_DLR => 0.00; use constant MAX_SUM_DLR => 999.99; use constant MIN_UNITS => 0; use constant MAX_UNITS => 99; use constant MIN_SUM_UNITS => 0; use constant MAX_SUM_UNITS => 999; use constant PCT_THRES_AO =>    1; use constant PCT_THRES_TRANS_CUST_BI => 20; use constant PCT_THRES_CUST => 3; 

Thanks @leon for the solution as well as others who chimed in with their inputs.

UPDATE: Another (more elegant) solution is to update your Perl version to the one that supports hash reference in declaring constants.

  • 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. 2026-05-11T03:45:45+00:00Added an answer on May 11, 2026 at 3:45 am

    The problem is that you are using a hash reference. The version of constant provided by perl 5.6.1 does not support that. You’ll either have to remove the braces or upgrade your constant.

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

Sidebar

Related Questions

Perl version: v5.10.1 (*) built for x86_64-linux-thread-multi I am using Spreadsheet::WriteExcel and I have
I have a Perl script running on version 5.10 build 1004 of ActiveStates Active
I have a Perl script that takes user input and creates another script that
I have a perl script URL which gives me a ZIP file, it processes
I have a Perl script which maps two drives, and then proceeds to copy
I have a Perl script that uses WWW::Mechanize to read from a file and
I have a Perl script called replaceUp: #!/usr/bin/perl search=$1 replace=$2 find . -type f
I have built a tiny application in Perl that displays a graph over time.
I have this piece of script : #!/usr/bin/perl use strict; use warnings; use Data::Dumper;
Is there a built-in Perl variable that keeps track of how many records have

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.