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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:14:07+00:00 2026-06-11T23:14:07+00:00

Preceding a number with escape character ‘\’ produces garbage value Ex: $a = \12;

  • 0

Preceding a number with escape character ‘\’ produces garbage value
Ex:

$a = \12;
print $a;

This code gives below output

SCALAR(0x2001ea8)

and the output changes when I again execute the program.

If I take a value(number) from user when the user gives any input starting with zero, I dont want it to interpret as octal number. So I wanted to escape zero if the number starts with zero.

  • 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-11T23:14:08+00:00Added an answer on June 11, 2026 at 11:14 pm

    [In a comment, the OP explained he wants numbers input by the user to be treated as decimal even if they have leading zeroes.]

    In numerical literals (code that produces a number), a leading zero tells Perl that the number is in octal.

    $ perl -E'say 045'
    37
    

    But that does not apply to numification (converting a string to a number).

    # "045" is the same as reading 045 from handle or @ARGV.
    $ perl -E'say 0+"045"'
    45
    

    So you don’t have to do anything special. A 045 input by the user means forty-five (not thirty-seven) if you use it as a number.

    If for some reason you did need to get rid of the leading zero, you could use

    $var =~ s/^0+(?!\z)//;
    

    The (?!\z) makes sure "0" doesn’t become "".

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

Sidebar

Related Questions

From this article , /^1?$|^(11+?)\1+$/ checks whether a number(its value in unary) is prime
I have this code: File.foreach(testfile.txt) { |line| print line } lines = File.readlines(testfile.txt) lines.each
I am familiar with using preceding axes in XSLT for finding determining the number
Can I specify I want the preceding character to be either (NOT A DIGIT)
I have some code to clone the input field directly preceding the clone 'button'
I have a number of xml files that should follow this format: <root> <question>What
I am trying to write a simple module to output a 14-bit number based
For some reason Excel is converting my number into text and adding a preceding
I need to check whether a given date is in the preceding month for
I'm having trouble making divs top position be relative to its preceding subling. I

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.