Luinrandir wrote:
$Player{Location}=Inn
You are missing a semi-colon, and there is no reason to use double
quotes above.
require '$Player{Location}.pl'; #no error here, I think.
Single quotes don't interpolate.
'$Player{Location}'::HTML(); #error occurs here
I'd hate to have to make a
@perl.org
Sent: Wednesday, September 14, 2005 9:22 AM
Subject: Re: Why wont this work? Package require question
Luinrandir wrote:
$Player{Location}=Inn
You are missing a semi-colon, and there is no reason to use double
quotes above.
require '$Player{Location}.pl'; #no error here, I
No need to top post, please don't.
Luinrandir wrote:
Ok.. and i'm actually going to top post for this...
when done is should read
$Player{Location}=Inn;
require '$Player{Location}.pl';
whixh is the same as
require 'Inn.pl';
Same problems exist. Single quotes do NOT interpolate,
OK I got this to work
require $Player{Location}.pl;
but not
$Player{Location}::HTML(); #error
or
$Player{Location}::HTML(); # ignored completely!
or
'$Player{Location}::HTML()';# ignored completely!
or
'$Player{Location}'::HTML(); #error
or
$Player{Location}::HTML(); #error
now what?
hey.. and
Now you want to call the Inn::HTML() function, right? You can't easily do
it if strict is turned on. Here's one way, though:
my $glob = $main::{$Player{Location} . ::}{HTML};
$glob-();
ah yes.. must bottom post
ok
in the first line you set the var $glob to equal the package call
Now you want to call the Inn::HTML() function, right? You can't easily
do
it if strict is turned on. Here's one way, though:
my $glob = $main::{$Player{Location} . ::}{HTML};
$glob-();
Ok.. that works.. why?
what is
-()
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
I also got this to work:
$Player{Location}=Inn;
$Player{Action}=Sell;
require $Player{Location}.pl;
# this code calls on the package #
my $glob = $main::{$Player{Location} . ::}{$Player{Action}}; #
$glob-(); #
but what if I want to pass a var? then
$glob-($foo,$bar);
?
Yes sir.. we have a winner
But I still have no clue as to why this works... esp.
$glob-();
just looked in my book.. am I dereferencing a reference?
but hey!
thanks anyway!
Lou
$Player{Location}=Inn;
Jeff 'japhy' Pinyan wrote:
Now you want to call the Inn::HTML() function, right? You can't
easily do it if strict is turned on. Here's one way, though:
my $glob = $main::{$Player{Location} . ::}{HTML};
$glob-();
Or just turn off strict for a sec:
{ no strict 'refs';
On Sep 14, Luinrandir said:
but what if I want to pass a var? then
$glob-($foo,$bar);
?
But I still have no clue as to why this works... esp.
$glob-();
just looked in my book.. am I dereferencing a reference?
Basically, yes. $glob ends up being a glob, a reference to everything
with
10 matches
Mail list logo