Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Llama book appendix A ch12 - how in the world?

by zerogeek (Monk)
on May 15, 2006 at 23:17 UTC ( #549632=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-08-09 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?