Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Windows - dirname(__FILE__)

by fishy (Scribe)
on Apr 11, 2014 at 16:48 UTC ( #1081999=note: print w/ replies, xml ) Need Help??

in reply to Windows - dirname(__FILE__)

While your script don't chdir()

#!/usr/bin/perl use strict; use warnings; use Cwd; my $script_dirname = cwd; print "dirname: $script_dirname\n";

Comment on Re: Windows - dirname(__FILE__)
Download Code
Replies are listed 'Best First'.
Re^2: Windows - dirname(__FILE__)
by aitap (Deacon) on Apr 11, 2014 at 17:53 UTC

    Sadly, this won't work when script is called from another directory by full path:

    $ pwd /home/aitap $ cat /tmp/ #!/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/ dirname: /home/aitap script dirname: /tmp

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-11-25 14:50 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (679 votes), past polls