I apologize, at the time of writing I thought it was clear.
What is happening is I am looping through a list of files and I don't want to reprint the directory the files reside in for every single file. So I am trying to set $a to $b as $b changes and I am also setting $b to "" if it matches $a.
foreach $file (@filelist) {
($dir, $name) = split '/', $file;
$dir =~ s/$currentdir//;
printf("%s %s\n", $dir, $name);
$currentdir !~ s/$dir/$dir/;
}
so I will hopefully get output like
DIR1 FILE1
FILE2
FILE3
DIR2 FILE4