Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Help with Numbers..Please

by broquaint (Abbot)
on Apr 24, 2003 at 10:05 UTC ( [id://252826]=note: print w/replies, xml ) Need Help??


in reply to Help with Numbers..Please

Just make sure your number variable is a string e.g
my $n = "0001"; print "$n\n" and $n++ for 1 .. 5; __output__ 0001 0002 0003 0004 0005

HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Help with Numbers..Please
by dakkar (Hermit) on Apr 24, 2003 at 12:03 UTC

    The docs say that the "string magic increment" works with variables that

    has been used in only string contexts since it was set, and has a value that is not the empty string and matches the pattern "/^[a-zA-Z]*[0-9]*\z/"

    -- 
            dakkar - Mobilis in mobile
    

    Most of my code is tested...

    Perl is strongly typed, it just has very few types (Dan)

      Thanks for the warning. I have used the magical mystery increment quite often, and didn't realize that it could be problematic depending on previously used context for the variable. I'll have to look over some code to make sure (if I can find it), though I haven't had a problem with it yet.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-23 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found