Meneses, Alden wrote:
> I must be doing something wrong with this script....
> 
> my $pcname = 'ACME0001';
> while ( $pcname < 5 ) {
        I believe it has to do the arithmetic < which is making ACME0001 into 0 which 
then gets added to 0.

This is the code I used to verify it would work as stated:
my $MyIds = 'ACME0001';
for(my $MyId=0;$MyId<1300;$MyId++) {
    printf "%s\n", $MyIds++;
 }
 Wags ;)
>     print "$pcname \n";
>     $pcname++;
> }
> 
> I get these results
> 
> ACME0001
> 1
> 2
> 3
> 4
> 
> -----Original Message-----
> From: Wagner, David --- Senior Programmer Analyst --- WGO
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 12, 2004 11:50 AM
> To: James Edward Gray II; Meneses, Alden
> Cc: [EMAIL PROTECTED]
> Subject: RE: How do I increment a alphanumeric value?
> 
> 
> James Edward Gray II wrote:
>> On Mar 12, 2004, at 1:39 PM, Meneses, Alden wrote:
>> 
>>> Suppose I have machines that are ACMExxxx
>>> 
>>> I want to go from ACME0001 to ACME9999
>> 
>> How's this?
>       If you have it in a variable then you only need ++ to get to the
> next item:
>       my $MyMachines = 'ACME0001';
> 
>       # to get the next item
>       $MyMachines++;
> 
>       Seems to simple, but ran a test and it works just like that.
> 
> Wag ;)
>> 
>> foreach (1..9999) {
>>      printf "ACME%4d\n", $_;
>> }
>> 
>> James


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to