Changing working directory to script location in perl.
Another one of my memo`s. I had some trouble changing the working directory to the actual script location without the need to download all kinds of fancy modules. The solution i found to be working quite nicely was this one.
# We want the programmig to be clean! use strict; # We need to change the working directory to where # the script is. This is how 🙂 # Added by Chris. use Cwd 'abs_path'; my $path = abs_path($0); $path =~ s/scriptname.pl//gi; chdir($path);
Hope this helps anyone 🙂