You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by "Philip <test>" <pm...@aaanime.net> on 2001/06/25 01:43:54 UTC

XMLSubs inside strings?

Is there a way that I can use XMLSubs inside strings (it comes in useful
when I have to generate output that is not meant to be printed
immediately, such as when using Net::SMTP to send an e-mail message)?

This script will work:

<my:h1>Hello</my:h1>

but this will cause an error of "String found where operator expected":

print "<my:h1>Hello</my:h1>";

-Philip Mak (pmak@aaanime.net)


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: What is an application?

Posted by Thanos Chatziathanassiou <tc...@arx.gr>.
"John D. Leonard II" wrote:

> All:
>
> I've got a really simple question ... What defines the boundaries of an "ASP
> Application?"

I think (Josh, correct me if I'm wrong) the really simple answer is :
The boundaries are defined by the ``Global'' variable.
That is, if you state ``PerlSetVar Global /some/path/'', then all .asp files
affected by this will look in that specific directory for their global.asa, thus
ignoring any other global.asa files.
Consequently, defining ``PerlSetVar Global .'' will tell the asp files to look
for their global.asa in their current directory, so files in subdirs can have
their own.

> 1) Does the application include the current directory (i.e., any directory
> containing a "global.asa") and all subdirectories?  Or does it include only
> the current directory?
>
> 2) What happens when a child directory contains a global.asa?  Does the
> subdirectory become it's own application?
>
> 3) What happens when I request a page in a subdirectory (e.g.,
> http://www.myserver.com/parent/child1/default.asp) and the directory
> (child1) doesn't include a global.asa?  Does Apache::ASP look for a
> global.asa in the /parent?
>
> Thanks in advance,
>
> JL
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org

Thanos Chatziathanassiou



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: What is an application?

Posted by Joshua Chamas <jo...@chamas.com>.
"John D. Leonard II" wrote:
> 
> Joshua:
> 
> > The notion of application is mostly closely tied to where the global.asa
> > resides. This is configured with the PerlSetVar Global config,
> > and defaults to '.', the current directory of the executing script.
> 
> 1) Must all ASP "applications" have a .htaccess file?  A message earlier
> today suggested that existence of a .htaccess file caused a big performance
> hit.  If not, can "PerlSetVar Global wherever" be set on a per-directory
> basis in the httpd.conf?
> 

No, I only use a .htaccess in the ./site/eg samples for portability.
VirtualHost, Directory, Location tags can all have their own
PerlSetVar configs.  I use <Files> style tags in VirtualHosts personally,
so I can mix media.

> 2) How can I "localize" variables between different ASP files in the same
> application without having to resort to the PerlSetVar UniquePackages 1"?
> 

my $var = "bar"; # this is local to the script

The reason to use UniquePackages is when you want to defined subs
in scripts that might have the same name without having them conflict.
However subs should be decomped to a perl module if possible.

> For example, I have two scripts in the same directory (script1.asp and
> script2.asp) that both declare a variable (e.g.,  "my $filename =
> 'scrip1.txt'" and "my $filename='script2'").  If ASP compiles these scripts
> to the same package, is it possible to ensure that each script doesn't
> hammer on the $filename in the other script?  If not, is there a "clean" way

my scoping variables does this for you and is generally good coding
practice.  Also, set UseStrict, and this will complain about variables
not my scoped or declared as globals with "use vars qw()"

> to change the "default" package name in the ASP script with having to recode
> all subsequent perl (e.g., all $filename references to $NS1::filename and
> $NS2::filename.)
> 

You can probably do this if you need to by having ...

  package some_package;

in your script.  If you do this though, you will need to
reference ASP objects with $main::Server->Function() syntax.

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks <- Web Link Checking          Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


RE: What is an application?

Posted by "John D. Leonard II" <jo...@ce.gatech.edu>.
Joshua:

> The notion of application is mostly closely tied to where the global.asa
> resides. This is configured with the PerlSetVar Global config,
> and defaults to '.', the current directory of the executing script.

1) Must all ASP "applications" have a .htaccess file?  A message earlier
today suggested that existence of a .htaccess file caused a big performance
hit.  If not, can "PerlSetVar Global wherever" be set on a per-directory
basis in the httpd.conf?


2) How can I "localize" variables between different ASP files in the same
application without having to resort to the PerlSetVar UniquePackages 1"?

For example, I have two scripts in the same directory (script1.asp and
script2.asp) that both declare a variable (e.g.,  "my $filename =
'scrip1.txt'" and "my $filename='script2'").  If ASP compiles these scripts
to the same package, is it possible to ensure that each script doesn't
hammer on the $filename in the other script?  If not, is there a "clean" way
to change the "default" package name in the ASP script with having to recode
all subsequent perl (e.g., all $filename references to $NS1::filename and
$NS2::filename.)

More thanks,

JL


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: What is an application?

Posted by Joshua Chamas <jo...@chamas.com>.
"John D. Leonard II" wrote:
> 
> All:
> 
> I've got a really simple question ... What defines the boundaries of an "ASP
> Application?"
> 

The notion of application is mostly closely tied to where the global.asa 
resides. This is configured with the PerlSetVar Global config, and defaults 
to '.', the current directory of the executing script.

> 1) Does the application include the current directory (i.e., any directory
> containing a "global.asa") and all subdirectories?  Or does it include only
> the current directory?
> 

I can have scripts in lots of subdirectories, and if my PerlSetVar Global
config is the same for all of them, they are part of the same application.

> 2) What happens when a child directory contains a global.asa?  Does the
> subdirectory become it's own application?
> 

Only if Global is set to that directory, or is left unset, and defaults
to that local global.asa.

> 3) What happens when I request a page in a subdirectory (e.g.,
> http://www.myserver.com/parent/child1/default.asp) and the directory
> (child1) doesn't include a global.asa?  Does Apache::ASP look for a
> global.asa in the /parent?
> 

No.

Be careful also to pay attention to where StateDir is set.  This
can be set independent of Global, and controls where data for 
$Session and $Application is stored.  Thus, you could actually
share data across applications if StateDir were set to be the 
same for each.

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks <- Web Link Checking          Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


What is an application?

Posted by "John D. Leonard II" <jo...@ce.gatech.edu>.
All:

I've got a really simple question ... What defines the boundaries of an "ASP
Application?"

1) Does the application include the current directory (i.e., any directory
containing a "global.asa") and all subdirectories?  Or does it include only
the current directory?

2) What happens when a child directory contains a global.asa?  Does the
subdirectory become it's own application?

3) What happens when I request a page in a subdirectory (e.g.,
http://www.myserver.com/parent/child1/default.asp) and the directory
(child1) doesn't include a global.asa?  Does Apache::ASP look for a
global.asa in the /parent?

Thanks in advance,

JL


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: XMLSubs inside strings?

Posted by Joshua Chamas <jo...@chamas.com>.
"Philip " wrote:
> 
> Is there a way that I can use XMLSubs inside strings (it comes in useful
> when I have to generate output that is not meant to be printed
> immediately, such as when using Net::SMTP to send an e-mail message)?
> 
> This script will work:
> 
> <my:h1>Hello</my:h1>
> 
> but this will cause an error of "String found where operator expected":
> 
> print "<my:h1>Hello</my:h1>";
> 

No, though you could call your XMLSubs yourself directly
by using the perl version...

print &my::hi({}, 'Hello');

I know its not the same, I'm just trying to be helpful.

You might also consider doing something like:

my $output_ref = $Response->TrapInclude('mail.inc', @args)
$Server->RegisterCleanup(sub { 
  $Server->Mail(Body => $$output_ref) 
});

I'm only suggesting this because it seems you want to 
generate email output from an ASP script, so you can 
use TrapInclude() for this, capture the output and
process it through your favorite mailer.

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks <- Web Link Checking          Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org