[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Unique File Name



>I'm trying to check if a file exists, and if it does, increment the name
>and create a new one.
>
>So if the file 07141998.html exists, I want to create 07141998_1.html
>(of course I need to check if _that_ exists first...)

Here's how I do it:

  $name = ..... # whatever
  if (-e $name) {
    for (my $i = 1; -e ($name = $name."_$i"); $i++) {};   # get unique name
  }



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch