User Control Panel
Advertisements

HELP US, HELP YOU!

problem with includes.

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Wed Mar 23, 2005 9:35 am    Post subject: Reply with quote

This code is from Cers CKS-AIM bot.


Code:
#require stuff:<br /><br /><br />print ":: Loading Sub-files...\n\n\n";<br />my @folders = (<br /> './FILES/ext_subs/aimhandlers',  <br />);<br />foreach $item (@folders) {<br />   opendir (DIR, $item);<br />   foreach $file (sort(grep(!/^\./, readdir(DIR)))) {<br />  <br />  require "$item/$file";<br />   }<br />   closedir (DIR);<br />}<br /><br />


when i add another element to the @folders array like this

Code:
<br />my @folders = (<br /> './FILES/ext_subs/aimhandlers',   './FILES/ext_subs',  <br />);<br />


It doesn't work.

Error:

Quote:
MSN 2.0 (01/21/2005) Rev: 84  - Checksum: 60117-NS36016-SB26593

:: Loading Sub-files...


Can't locate ./FILES/ext_subs/aimhandlers in @INC (@INC contains: ./Lib C:/Perl/
lib C:/Perl/site/lib .) at bot.pl line 38.



Any ideas?
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Mar 23, 2005 12:39 pm    Post subject: Reply with quote

It's because your ./FILES/ext_subs doesn't contain only PL files; it also contains the folder "aimhandlers" - so when it gets to "aimhandlers" it tries requiring it, and it's not valid Perl code--it's not valid ANY code--it's a folder.

You'll have to do a check for the PL extension for each $file like this:
Code:
next unless $file =~ /\.pl$/i;


That will make it go to the next file unless it ends with ".pl" (you should do that check first thing in the foreach loop, before it tries requiring it).

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group