in reply to comparing folders
if ($file eq "@onefile")It probably doesn't work because those double quotes will interpolate all the elements of the array into a single string (with a single space between each element). Since readdir returns all of a directory's contents, @onefile probably has 3 elements: the file you expect to be there and the special dot directories (. and ..). You should filter the output with grep -f, or use nested for loops (one for each array), or load the first files into a hash.
Inspect the contents of your array using Data::Dumper (tip #4 from the Basic debugging checklist):
use Data::Dumper; print Dumper(\@onefile);
You should be able to adapt the solution to a similar problem: Re: Comparing Directories and copy files
rename("$onefile", "@onefile_1.txt");To append _1, you really want something like this:
rename $onefile, $onefile . '_1.txt' or die "Can not rename: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing folders
by grmshw4 (Initiate) on Jul 28, 2010 at 20:23 UTC |