<?xml version="1.0" encoding="windows-1252"?>
<node id="70232" title="Re: Re: (GOLF)Re: Leading Zeros w/ increment" created="2001-04-05 19:12:52" updated="2005-08-14 18:14:49">
<type id="11">
note</type>
<author id="20087">
extremely</author>
<data>
<field name="doctext">
If you don't need to pad then &lt;tt&gt;$count++&lt;/tt&gt; works fine.
The trick to this all is that perl's &lt;tt&gt;++&lt;/tt&gt; is magical
on some strings. Try these:
&lt;code&gt;
my ($a, $b, $c, $d, $e) = ("aaa", "ab000", "123", "00123", "321ba",);
$a++;
$b++;
$c++;
$d++;
$e++;
print "a=$a\nb=$b\nc=$c\nd=$d\ne=$e\n"
&lt;/code&gt;
&lt;p&gt;You'll notice when you run those that &lt;tt&gt;$e&lt;/tt&gt; gets
chopped to just numbers. In fact, my stunting isn't really
necessary since perl will happily leave the "00" on the front of &lt;tt&gt;$d&lt;/tt&gt;!  The only trick to it is never treating $d as a number. Look at this:
&lt;code&gt;
# now that is golfing.
perl -e '$a="0035";until("$a"&gt;50){print++$a,$/}'
&lt;/code&gt;
&lt;p&gt;Cute huh?  Perl is like a squirrel's nest.  Good stuff is everywhere but most of it is nuts...
&lt;p&gt;Your code could be re-updated to have quotes around &lt;tt&gt;"$String"&lt;/tt&gt; in the comparison for the loop and just have &lt;tt&gt;$String++&lt;/tt&gt; where the "magical" part was.  Sad that I didn't even know how slick it was.  My stunt kept the
comparison from blasting the string but it is better just to
never treat it numerically.
&lt;p&gt;&lt;i&gt;-- &lt;br&gt;
$you = new YOU;&lt;br&gt;
honk() if $you-&gt;love(perl)&lt;/i&gt;</field>
<field name="root_node">
69912</field>
<field name="parent_node">
70222</field>
</data>
</node>
