Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-02-21 01:40 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (305 votes). Check out past polls.