Sadly, this won't work when script is called from another directory by full path:
$ pwd /home/aitap $ cat /tmp/1.pl #!/usr/bin/perl use strict; use warnings; use Cwd; my $script_dirname = cwd; print "dirname: $script_dirname\n"; use Cwd 'abs_path'; use File::Basename; $script_dirname = dirname(abs_path($0)); print "script dirname: $script_dirname\n"; $ perl /tmp/1.pl dirname: /home/aitap script dirname: /tmp
In reply to Re^2: Windows - dirname(__FILE__)
by aitap
in thread Windows - dirname(__FILE__)
by demichi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |