Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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.

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

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 imbibing at the Monastery: (7)
As of 2015-11-25 01:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (666 votes), past polls