in reply to Reorganizing Files in a Directory
Gday, I like your code, it seems familiar :-) A few quick points:
1 I don't understand what your question is. What exactly do you want to do? Many monks will not have seen A monk in training with a problem so you will need to spell things out carefully. Usually you continue to post under that node but if there has been a significant delay (ie over a day!) a new post often helps to get your problem back on the radar screen at newest nodes.
2 When you post code the shorter the better - you can ditch all the comments. I added these for your benefit but here they just make the code look long which it is not. When I see a big chunk of code I tend to go - bzzt - failure to reduce code to short test case - jump to next node.
3 Long variable names are descriptive but once you get too long *typos* become far more common.
4 I presume that the commented out code at the end is trying to rename the files and write a text file.
Here is how you might do that.
<begin_standard_disclaimer>Warning totally untested, I'm just making this up as I go.</end_standard_disclaimer>
open (FILE, ">data.txt") or die "Oops! Perl whines: $!\n"; for my $i (0..$#screenres) { rename "$base_dir/$screenres[$i]", "$base_dir/".$i."_sc.jpg" or d +ie "Rename failure, Perl moans: $!\n"; print FILE "Renamed $base_dir/$screenres[$i] to $base_dir/".$i."_ +sc.jpg\n"; # continue in the same vein as required } close FILE;
*Important note* when you open a file for writing with > you *stomp* on the old file, ie overwrite it! If you want to append to (ie add to the end of) an existing file without erasing the existing data you use >>
# opens data.txt for writing, *erases* old data.txt open (FILE, ">data.txt") # opens data.txt for appending, adds data to end of data.txt open (FILE, ">>data.txt")
Hope this helps
cheers
tachyon
|
|---|