> SubbaReddy M wrote:
> 
> Hello Gurus,
> 
> How to access a scalar variable in *.asp file, which declared in global.asa file?
> Though it is declared as use vars($title) in global.asa, unable access the $title 
>variable in *.asp file.
> 

# in global.asa
my $Var = "first project";

# in script
<% print $Var; %>

Scripts are compiled into the same package as the global.asa, which is why 
you can share variables in this way.

> So, I tried to put in $Application{'title'} = "This is my 1st Apache::ASP project"; 
>in global.asa
> and tried to print in *.asp file.

This should have been an error.  Remember to configure "PerlSetVar UseStrict 1",
which should have reported this as an error if configured.  The reason
is that %Application is not defined, which $Application{'title'} would
reference.  Rather $Application should be defined, so you could do
$Application->{title} = "This is my 1st...";

This should work.  But generally, unless you have a very good reason
for using $Application, don't!  It can be a big performance drag
on a site if not used carefully.  Things in $Application can often
by defined as globals in Script_OnStart, or in the global.asa file
as above like $Var.

# global.asa
use vars qw( %Strings ); # declare globals

%Strings = (
        'error' => 'This is an error',
        'greeting' => 'This is a greeting.'
        );

# then in ASP script
<%= $Strings{'error'} %>

> I have declared variable $title in global.asa
> and when I tried to access http://192.168.1.235/aps/1.asp
> 
> I am getting error page.
> 

What's the error page?

> 
> >>>>>>>>>> global.asa    >>>>>>>>>>>
> $MLDBM::RemoveTaint = 1;
> use vars qw($title);
> 

If you want to init $title on a per script request, then 
you probably want to set it to something either in your script like
  <% $title = "something"; %>

or in global.asa Script_OnStart

sub Script_OnStart {
  $title = "title here";
}

> sub Application_OnStart {
>         $Response->AppendToLog("Application_OnStart! global.asa");
>         $Application->{Count} = 20;
>         $title = "FrontlineSoft limited";
> }
> 

Not in Application_OnStart though.  Application_OnStart gets fired
only when your web site is starting up when the first user visits
it, and is thus not very useful.

-- Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to