|Syntactic Confectionery Delight|
How could you make a script think it's running in its own directory?by why_bird (Pilgrim)
|on Mar 27, 2008 at 09:16 UTC ( #676660=perlquestion: print w/replies, xml )||Need Help??|
why_bird has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way of tricking a perl script into thinking I'm running it from it's own directory, even when I'm running it from somewhere else?
For example, I have a script called backup.pl, and I want to create an alias to just type 'backup' in the shell and for that to run my backup.pl. However, the way I've written it, it needs to run in it's own directory (e.g. to create dated folders in ~/other/BACKUP/ which is where the script resides..)I suppose I could hard-code all the file names etc in the file, but having written it badly :O (but also out of general interest in understanding how these things work) I'm wondering if there's any way to tell it that I want it to create the folders in it's own folder rather than where I run it from. cheers, why_bird
Those are my principles. If you don't like them I have others.
-- Groucho Marx
Back to Seekers of Perl Wisdom