Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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;


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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2016-10-26 05:42 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (336 votes). Check out past polls.