Have a look at Auto-increment and Auto-decrement
In particular: "The auto-increment operator has a little extra builtin magic to it."
Combined with neversaint's suggestion you may be able to dispense with the $i altogether.
As Dolly Parton famously said about looking at the docs: "That's what they're for!". Although she might not have been talking about the docs. :-)
Update
In reply to Re: unique filename
by wfsp
in thread unique filename
by lax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |