http://qs321.pair.com?node_id=698911


in reply to Rename File Name in Array

It "doesn't work", because $ext is reset to "A" on every iteration. You need to declare and initialize that variable outside the loop.

To update $x->[0] after the rename, simply do $x->[0] = "USB" . $ext;.

Replies are listed 'Best First'.
Re^2: Rename File Name in Array
by drodinthe559 (Monk) on Jul 20, 2008 at 11:25 UTC
    Thanks, I knew it was something cheesy.
      Is there anyway to report that the renaming was successful?
        rename ($x->[0], "USB" . $ext) and print "rename was successful.\n";

        (rename returns true for success, false otherwise.)