472,103 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,103 software developers and data experts.

What directory perl script is being run from? - followup

R D
Thanks for quick reply.

Cwd didn't work because it gives what directory
you are currently in not the directory the script is in!

Can't get FindBin to work..any idea what's wrong with the following?

my $Bin;
use FindBin qw($Bin);
use lib "$Bin/../lib";
print $Bin;
My apologies for posting aout easy stuff but I don't use Perl
normally..just doing a quick hack to someone else's script!

Thanks again.

"Jürgen Exner" <ju******@hotmail.com> wrote in
news:_l**************@nwrddc01.gnilink.net:
R D wrote:
How do I get a *Windows* perl script to figure out what directory it is being run from/


perldoc Cwd
exists in?


perldoc FindBin

jue

Jul 19 '05 #1
1 6601
On Fri, 19 Mar 2004 at 16:11 GMT, R D <rk*@myrealbox.com> wrote:
Thanks for quick reply.

Cwd didn't work because it gives what directory
you are currently in not the directory the script is in!

Can't get FindBin to work..any idea what's wrong with the following?

You forgot to:

#!/usr/bin/perl
use strict;
use warnings;
my $Bin; ^^^^^^^
Oops! You just declared a lexical variable, obscuring
$FindBin::Bin that you are going to import in the next use
statement. You should have could this yourself because you
are using warnings, aren't you? Always, always "use strict"
and "use warnings".
use FindBin qw($Bin);
use lib "$Bin/../lib";
print $Bin;


Now it prints correctly the path where your script is located.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by R D | last post: by
8 posts views Thread by Shabam | last post: by
121 posts views Thread by typingcat | last post: by
8 posts views Thread by Midnight Java Junkie | last post: by
5 posts views Thread by Karyn Williams | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.