LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2008, 09:56 AM   #1
sogenant
LQ Newbie
 
Registered: Dec 2007
Posts: 14

Rep: Reputation: 0
perl - @INC doesn't include current directory


For some reason when I run perl scripts, "require" doesn't search the
current directory. I think this is non-standard and want to fix it.
I'm using Slackware 12.0 and Perl 5.8.8.

If I run:

$ perl -V
the output looks good, and at the end it says:
@INC:
/usr/lib/perl5/5.8.8/i486-linux-thread-multi
/usr/lib/perl5/5.8.8
/usr/lib/perl5/site_perl/5.8.8/i486-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
.

But if I put this in a script:
#!/usr/bin/perl -t
print @INC ;

The directories printed don't include "."

In my scripts, to use included code from cwd, I have to say "require
./filename", otherwise it doesn't find filename.
 
Old 05-07-2008, 02:54 PM   #2
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
You may just "push" whatever dir you need to @INC.

BEGIN { push @INC,'.'; }

Or you add "." to the environment variable "PERL5LIB".

See

perl -e "print @INC;" and

perl -te "BEGIN { push @INC, '.'; } print @INC;"

Propably the taint-flags change the behavior (-t and -T) - compare the output of "perl -V" and "perl -Vt".
 
Old 05-08-2008, 09:59 AM   #3
sogenant
LQ Newbie
 
Registered: Dec 2007
Posts: 14

Original Poster
Rep: Reputation: 0
perl - @INC doesn't include current directory

Thanks su-shee, evidently this was just my early-onset senility - you are right that -t was what caused the problem in my example. Problem was with the keyboard/chair connector.
 
  


Reply

Tags
inc, perl, slackware


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
move all files in current directory into a subdirectory in the current directory jakykong Linux - Newbie 8 07-16-2013 11:46 PM
How to know my current Linux Kernel can support how many files system include R&W. hocheetiong Linux - Newbie 1 09-11-2007 08:13 AM
Does -current include latest KDE security patches ?? small_boy22 Slackware 4 06-03-2005 02:09 PM
edit path environment variable to include current working directory alb1954 Linux - Newbie 8 07-11-2004 11:26 PM
Perl Script include mikeshn Programming 1 08-20-2002 09:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration