User Control Panel
Advertisements

HELP US, HELP YOU!

External file.

 
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: Sat Mar 05, 2005 5:45 am    Post subject: Reply with quote

I have a handler in an external file. It is required at the start of the code.

Inside the sub in this file the $bot variable is required but cannot be found.


Another sub (in bot.pl) uses the bot variable, and it doesn't seem to be passed (it too is a handler)


Any ideas?
Back to top
M4RTIN
Member
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Sat Mar 05, 2005 8:02 am    Post subject: Reply with quote

Could be a couple of things, Maybe a typo error.

Or make sure this isnt wrong:

Code:
  $bot = do("./Storage/Settings.dat");


Only things i can think of sorry Smile
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Sat Mar 05, 2005 10:40 am    Post subject: Reply with quote

If you use my in your code its a local variable so wont work in external.
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Sat Mar 05, 2005 6:05 pm    Post subject: Reply with quote

The complete lack of code makes it impossible to help you. This kind of issues are why globals are bad. Instead of using globals you should be passing the variables. Then you would know exactly where and what each value was and you wouldn't have to guess. If you do want help with this though you will have to provide more information and code.
_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Sat Mar 05, 2005 7:04 pm    Post subject: Reply with quote

I had this problem when I started using strict in my bots. To declare a variable or hashref or whatever as global, so that all the included files and subroutines can use it, declare it with "our" instead of "my"

Example:
our $bot = {};

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
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: Mon Mar 07, 2005 8:40 am    Post subject: Reply with quote

Thanks Cer! That works, my lack of understanding of external files it seems was the problem, i was thinking they would work something like php includes.

btw, i couldnt exactly pass them, it was called by a handler correct me if i'm wrong....
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Mar 07, 2005 4:21 pm    Post subject: Reply with quote

QUOTE(draget @ Mar 7 2005, 03:40 AM)
Thanks Cer! That works, my lack of understanding of external files it seems was the problem, i was thinking they would work something like php includes.

btw, i couldnt exactly pass them, it was called by a handler correct me if i'm wrong....
[right][snapback]46463[/snapback][/right]

You DO understand the concept of passing variables to subs right? And...PHP may be similar to Perl, but it is NOT Perl. You shouldn't be expecting Perl to act the same way.

_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
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: Tue Mar 08, 2005 9:32 am    Post subject: Reply with quote

I know how to pass variables.

the sub is called by a handler

you make no sense at all.
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Mar 08, 2005 7:04 pm    Post subject: Reply with quote

I make no sense because I asked you if you knew about that concept and told you Perl isn't the same as PHP? LOL Ok, whatever. Get some sense yourself before you start telling others they need some.
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
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: Fri Mar 11, 2005 5:02 am    Post subject: Reply with quote

QUOTE(alienz @ Mar 8 2005, 11:04 AM)
I make no sense because I asked you if you knew about that concept and told you Perl isn't the same as PHP? LOL Ok, whatever. Get some sense yourself before you start telling others they need some.
[right][snapback]46640[/snapback][/right]



where does PHP come into this in the first place?
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