in reply to Re: Add timestamp to file being copied.
in thread Add timestamp to file being copied.
my $newfilename = "$filenamearray[0]" . "-" . $hr . ":" . $min . ":" . + $sec . "\." . $filenamearray[1];
In such cases, I personally prefer interpolation over concatenation:
my $newfilename = "$filenamearray[0]-$hr:$min:$sec.$filenamearray[1]";
Appears less cluttered to my eyes (YMMV). As there's nothing special about either '-', '.' or (single) ':' in double quoted strings, and they can't be part of variable names, you can write them just as is.
Or maybe use sprintf() to get regular zero-padded 2-digit format:
my $newfilename = sprintf "%s-%02d:%02d:%02d.%s", $filenamearray[0], $ +hr,$min,$sec, $filenamearray[1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Add timestamp to file being copied.
by Karger78 (Beadle) on Jun 09, 2009 at 13:19 UTC | |
by Karger78 (Beadle) on Jun 09, 2009 at 18:53 UTC |