Re: @INC and cross-platform path usage

2008-07-13 Thread Rob Dixon
Tobias Eichner wrote: > I have created a Perl library that I want to use with my programs (via > require). However the Perl library should be placed at a sub-folder of the > working directory (the place where the program runs). > > For example: > > /my/custom/path/ is the location of the program

Re: @INC and cross-platform path usage

2008-07-03 Thread Gunnar Hjalmarsson
Jay Savage wrote: On Tue, Jul 1, 2008 at 11:30 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: Thomas Bätzler wrote: Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: Some would suggest the use of the FindBin module. It does the right thing, but unfortunately it is known to be buggy. Actually,

Re: @INC and cross-platform path usage

2008-07-02 Thread Tobias Eichner
@Gunnar Hjalmarsson: > To me it seems as there is no perfect method. As long as you invoke your > program from command line, perhaps FindBin is the best choice. But since > you are going to write CGI programs, FindBin's failure as regards > mod_perl is not insignificant. Therefore I'd stick with

Re: @INC and cross-platform path usage

2008-07-02 Thread Jay Savage
On Tue, Jul 1, 2008 at 11:30 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Thomas Bätzler wrote: >> >> Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: >>> >>> Some would suggest the use of the FindBin module. It does the right >>> thing, but unfortunately it is known to be buggy. >> >> Actually

Re: @INC and cross-platform path usage

2008-07-02 Thread Gunnar Hjalmarsson
Tobias Eichner wrote: Giving it a closer look, I experience a strange behaviour. I'm using ActiveState Perl on WinXp here. The following script has been used for testing: use File::Spec; BEGIN { my ($volume,$softwaredir,$librarydir); ($volume,$softwaredir) = File::Spec->splitpath(

Re: AW: AW: @INC and cross-platform path usage

2008-07-02 Thread Jenda Krynicky
From: Tobias Eichner <[EMAIL PROTECTED]> > @Gunnar Hjalmarsson: > > > use File::Spec; > > my ($vol, $progdir); > > BEGIN { ($vol, $progdir) = File::Spec->splitpath( __FILE__ ) } > > use lib File::Spec->catpath( $vol, $progdir, 'libraries' ); > > At http://perldoc.perl.org/perl

Re: Re: Re: @INC and cross-platform path usage

2008-07-02 Thread Jenda Krynicky
From: "Amit Saxena" <[EMAIL PROTECTED]> > I still doubt whether > > * unshift (@INC,$librarydir);* > > works or not. > > To the best I have read the articles and tutorials, @INC can't be updated in > this way. Then you've read them wrong. Of course you can use unshift() on @INC, you just have

Re: @INC and cross-platform path usage

2008-07-02 Thread Tobias Eichner
@Gunnar Hjalmarsson: > That code is executed at runtime, and hence lets you require() modules > at runtime. If you want to use() a module instead, you need to make the > code be executed at compile time. You can do that by putting the code in > a BEGIN block. Thanks for noting. I've considered

Re: @INC and cross-platform path usage

2008-07-02 Thread Gunnar Hjalmarsson
Tobias Eichner wrote: I wrote the following script that fits my needs; maybe someone finds it useful, maybe someone finds an error in it (if so, let me know - I tested it on OS X and Win XP): use File::Spec; my ($volume,$softwaredir,$librarydir); ($volume,$softwaredir) = File::Spec->splitpath

Re: @INC and cross-platform path usage

2008-07-02 Thread Gunnar Hjalmarsson
Amit Saxena wrote: I still doubt whether * unshift (@INC,$librarydir);* works or not. To the best I have read the articles and tutorials, @INC can't be updated in this way. Where did you read that? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-ma

Re: Re: Re: @INC and cross-platform path usage

2008-07-02 Thread Tobias Eichner
Giving it a closer look, I experience a strange behaviour. I'm using ActiveState Perl on WinXp here. The following script has been used for testing: use File::Spec; BEGIN { my ($volume,$softwaredir,$librarydir); ($volume,$softwaredir) = File::Spec->splitpath(__FILE__); $libraryd

Re: Re: Re: @INC and cross-platform path usage

2008-07-02 Thread Tobias Eichner
> * unshift (@INC,$librarydir);* ... > To the best I have read the articles and tutorials, @INC can't be updated in > this way. What I read about is that paths can't be deleted easily from @INC, but I haven' tried it yet (since I don't see an application deleting a path that others have set at @

Re: Re: Re: @INC and cross-platform path usage

2008-07-02 Thread Amit Saxena
Hi I still doubt whether * unshift (@INC,$librarydir);* works or not. To the best I have read the articles and tutorials, @INC can't be updated in this way. You have to either use one of the options below :- - *PERL5LIB* environment variable - using *use lib ("")* construct - use *Fi

Re: Re: Re: @INC and cross-platform path usage

2008-07-02 Thread Tobias Eichner
I wrote the following script that fits my needs; maybe someone finds it useful, maybe someone finds an error in it (if so, let me know - I tested it on OS X and Win XP): use File::Spec; my ($volume,$softwaredir,$librarydir); ($volume,$softwaredir) = File::Spec->splitpath(__FILE__); $librarydir

Re: AW: AW: @INC and cross-platform path usage

2008-07-01 Thread Gunnar Hjalmarsson
Tobias Eichner wrote: @Gunnar Hjalmarsson: use File::Spec; my ($vol, $progdir); BEGIN { ($vol, $progdir) = File::Spec->splitpath( __FILE__ ) } use lib File::Spec->catpath( $vol, $progdir, 'libraries' ); At http://perldoc.perl.org/perldata.html it is stated that __FILE__ c

AW: AW: @INC and cross-platform path usage

2008-07-01 Thread Tobias Eichner
@Gunnar Hjalmarsson: > use File::Spec; > my ($vol, $progdir); > BEGIN { ($vol, $progdir) = File::Spec->splitpath( __FILE__ ) } > use lib File::Spec->catpath( $vol, $progdir, 'libraries' ); At http://perldoc.perl.org/perldata.html it is stated that __FILE__ contains the curren

Re: AW: @INC and cross-platform path usage

2008-07-01 Thread Gunnar Hjalmarsson
Tobias Eichner wrote: Gunnar Hjalmarsson wrote: Both those methods assume that the path to the directory where the program resides equals the current working directory. That's often the case, but not always. Isn't the "working directory" always the path where the program executes from ? No

Re: @INC and cross-platform path usage

2008-07-01 Thread Gunnar Hjalmarsson
Thomas Bätzler wrote: Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: Some would suggest the use of the FindBin module. It does the right thing, but unfortunately it is known to be buggy. Actually, I wish more modules were as "buggy" as FindBin ;-) I.e. that they would work robustly for all of

Re: @INC and cross-platform path usage

2008-07-01 Thread Rob Dixon
Tobias Eichner wrote: > > I have created a Perl library that I want to use with my programs (via > require). However the Perl library should be placed at a sub-folder of the > working directory (the place where the program runs). > > For example: > > /my/custom/path/ is the location of the progra

RE: @INC and cross-platform path usage

2008-07-01 Thread Thomas Bätzler
Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Some would suggest the use of the FindBin module. It does the > right thing, but unfortunately it is known to be buggy. Actually, I wish more modules were as "buggy" as FindBin ;-) I.e. that they would work robustly for all of the common usage case

RE: @INC and cross-platform path usage

2008-07-01 Thread Thomas Bätzler
Tobias Eichner <[EMAIL PROTECTED]> wrote: > I have created a Perl library that I want to use with my > programs (via require). However the Perl library should be > placed at a sub-folder of the working directory (the place > where the program runs). > > For example: > > /my/custom/path/ is the

AW: @INC and cross-platform path usage

2008-07-01 Thread Tobias Eichner
PERL5LIB is no choice, since there would be the same issue of how to write paths a cross-platform way. > Both those methods assume that the path to the directory where the > program resides equals the current working directory. That's often the > case, but not always. Isn't the "working direct

Re: @INC and cross-platform path usage

2008-07-01 Thread Amit Saxena
You can also set the environment variable PERL5LIB to whatever directory that contains your custom library files. Regards, Amit Saxena On Tue, Jul 1, 2008 at 6:32 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Tobias Eichner wrote: > >> I have created a Perl library that I want to use with

Re: @INC and cross-platform path usage

2008-07-01 Thread Gunnar Hjalmarsson
Tobias Eichner wrote: I have created a Perl library that I want to use with my programs (via require). However the Perl library should be placed at a sub-folder of the working directory (the place where the program runs). For example: /my/custom/path/ is the location of the program. /my/custom/

@INC and cross-platform path usage

2008-07-01 Thread Tobias Eichner
I have created a Perl library that I want to use with my programs (via require). However the Perl library should be placed at a sub-folder of the working directory (the place where the program runs). For example: /my/custom/path/ is the location of the program. /my/custom/path/libraries/ is the