Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-08-02 17:28 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (9 votes), past polls