Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: User variables with two values?

by Kenosis (Priest)
on Aug 19, 2012 at 21:49 UTC ( #988363=note: print w/ replies, xml ) Need Help??


in reply to User variables with two values?

Unless I'm misunderstanding your question, you can do it like this:

use Modern::Perl; my $a = '0001'; say 'The variable $a contains: ', $a; say 'The sum of $a and 1 is: ', $a + 1;

Output:

The variable $a contains: 0001 The sum of $a and 1 is: 2

The perl interpreter uses context to determine how a variable should be treated: as a string in the first case, and as an integer in the second.

Update: Yes, I did misunderstand. DamianConway provides an excellent solution below.


Comment on Re: User variables with two values?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988363]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-09-19 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls