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, meaning the value
of the variable is not replaced, the variable name itself is being used.
So Perl is looking for a file called $Player{Location}.pl which probably
doesn't exist.  Double quotes DO interpolate, but when you don't need to
interpolate use single quotes. So,

$Player{Location} = 'Inn';  # single quotes are fine

require "$Player{Location}.pl";  # double quotes for interpolation

Theoretically this should work if I remember 'require's specs correctly.
Though these days I would switch to 'use' and bring in both libraries
unless they are really huge, and not worry about the run time consequences.

> and then
> '$Player{Location}'::HTML();

Again, you would need to use double quotes, but in the above you might
be able to get away with or may be required to avoid stringification. So
either,

"$Player{Location}"::HTML();

or

$Player{Location}::HTML();

Either way single quotes will NOT work.  The above also assumes that you
have included the proper package statements in the required library.

perldoc -f package

> which is the same as
> Inn::HTML(); 
> 
> Do i have the vars correct so that if I want to change 
> $Player{Location}="Inn";
> to 
> $Player{Location}="Gate";
> the program would require the correct package
> require "Gate.pl"
> and the call on the sub HTML in that package?
> Gate::HTML();
> 

Not the vars that matter, it is the quoting.

http://danconia.org

[snip old messages]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to