http://qs1969.pair.com?node_id=549632


in reply to Llama book appendix A ch12 - how in the world?

OK, I sat back down on this one and figured it out:

#!/usr/bin/perl -w use strict; ########################## # # # Coded by Scott J Ulmen # # # ########################## my $source; my $dest; ($source, $dest) = @ARGV; my $new = "$dest".'/'."$source"; if (-d $dest) { rename $source, $new; } elsif (-e $dest) { print "Sorry, $dest already exists in this dir!\n"; } else { rename $source, $dest; }

Granted, I should add a regex to determine if the dir that I type in has a trailing "/", but it gets the job done an an exercise for the idea being presented WITHOUT A MODULE.

I have to admit that I was a bit upset that I couldn't get pointed in the right direction, but I'm glad now that nobody posted an answer as it mad me sit down today to figure it out. (I can be stubborn at times) :)

Apparently, my problem was simply with the ORDER of the else's. Man did that drive me crazy! To the point that I tried to rewrite it at least 4 different ways before coming back to my 1st try.