Question about open()

Question about open()

am 07.02.2008 04:06:05 von Mag Gam

------=_Part_17631_33382991.1202353565629
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,

I have been using mod_perl, and I have several perl-cgi files that use the
open(). I use this function to open/include my header, footer, basically a
poor man template system. Currently, when I open a file I have to use the
absolute path (/var/www/appname/top.inc). Is it possible for me to use just
'top.inc'? I think it trying to read from DocumentRoot, which is causing the
issue. Has anyone ever faced this?

TIA

------=_Part_17631_33382991.1202353565629
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,

I have been using mod_perl, and I have several perl-cgi files that use the open(). I use this function to open/include my header, footer, basically a poor man template system. Currently, when I open a file I have to use the absolute  path (/var/www/appname/top.inc). Is it possible for me to use just 'top.inc'? I think it trying to read from DocumentRoot, which is causing the issue. Has anyone ever faced this?


TIA


------=_Part_17631_33382991.1202353565629--

Re: Question about open()

am 07.02.2008 04:10:08 von roberto

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 06, 2008 at 10:06:05PM -0500, Mag Gam wrote:
> Hi All,
>=20
> I have been using mod_perl, and I have several perl-cgi files that use the
> open(). I use this function to open/include my header, footer, basically a
> poor man template system. Currently, when I open a file I have to use the
> absolute path (/var/www/appname/top.inc). Is it possible for me to use j=
ust
> 'top.inc'? I think it trying to read from DocumentRoot, which is causing =
the
> issue. Has anyone ever faced this?
>=20
I just set something like this in global.asa:

my $base_dir =3D cwd . '/';

Then I can make the $base_dir available globally and just use that
anywhere I need to refer to an on disk file.

Regards,

-Roberto

--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com

--nFreZHaLTZJo0R7j
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHqnaQ5SXWIKfIlGQRAui5AKCb+dxo6Se7QhTUsKYnIbYUdzcoSwCg uzi8
+yLFnkIF7CcF2aw4eBc/jnE=
=y9pZ
-----END PGP SIGNATURE-----

--nFreZHaLTZJo0R7j--

Re: Question about open()

am 07.02.2008 04:47:08 von Mag Gam

------=_Part_17730_13860571.1202356028661
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
Content-Disposition: inline

V2hhdCBpcyBnbG9iYWwuYXNhPwoKU29ycnksIEkgYW0gc29tZXdoYXQgbmV3 IGF0IHRoaXMuLi4K
CgpPbiBGZWIgNiwgMjAwOCAxMDoxMCBQTSwgUm9iZXJ0byBDLiBTw6FuY2hl eiA8cm9iZXJ0b0Bj
b25uZXhlci5jb20+IHdyb3RlOgoKPiBPbiBXZWQsIEZlYiAwNiwgMjAwOCBh dCAxMDowNjowNVBN
IC0wNTAwLCBNYWcgR2FtIHdyb3RlOgo+ID4gSGkgQWxsLAo+ID4KPiA+IEkg aGF2ZSBiZWVuIHVz
aW5nIG1vZF9wZXJsLCBhbmQgSSBoYXZlIHNldmVyYWwgcGVybC1jZ2kgZmls ZXMgdGhhdCB1c2UK
PiB0aGUKPiA+IG9wZW4oKS4gSSB1c2UgdGhpcyBmdW5jdGlvbiB0byBvcGVu L2luY2x1ZGUgbXkg
aGVhZGVyLCBmb290ZXIsIGJhc2ljYWxseQo+IGEKPiA+IHBvb3IgbWFuIHRl bXBsYXRlIHN5c3Rl
bS4gQ3VycmVudGx5LCB3aGVuIEkgb3BlbiBhIGZpbGUgSSBoYXZlIHRvIHVz ZQo+IHRoZQo+ID4g
YWJzb2x1dGUgIHBhdGggKC92YXIvd3d3L2FwcG5hbWUvdG9wLmluYykuIElz IGl0IHBvc3NpYmxl
IGZvciBtZSB0byB1c2UKPiBqdXN0Cj4gPiAndG9wLmluYyc/IEkgdGhpbmsg aXQgdHJ5aW5nIHRv
IHJlYWQgZnJvbSBEb2N1bWVudFJvb3QsIHdoaWNoIG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wWjxicj4t
LS0tLUVORCBQR1AgU0lHTkFUVVJFLS0tLS08YnI+Cjxicj48L2Jsb2NrcXVv dGU+PC9kaXY+PGJy
Pgo=
------=_Part_17730_13860571.1202356028661--

Re: Question about open()

am 07.02.2008 07:06:08 von roberto

--0lnxQi9hkpPO77W3
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 06, 2008 at 10:47:08PM -0500, Mag Gam wrote:
> What is global.asa?
>=20
> Sorry, I am somewhat new at this...
>=20
My mistake. I am using Apache::ASP (which is built on mod_perl) for
my pages. Sorry for the confusion.

Regards,

-Roberto

--=20
Roberto C. S=E1nchez
http://people.connexer.com/~roberto
http://www.connexer.com

--0lnxQi9hkpPO77W3
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHqp/P5SXWIKfIlGQRAslWAJ9ncPNQMwnpMr75B24drWdFAzZvCACg iwr9
gLxNg4+5SPVGcleAn8v1mZE=
=V1Dh
-----END PGP SIGNATURE-----

--0lnxQi9hkpPO77W3--

Re: Question about open()

am 07.02.2008 16:54:01 von brett lee

=0AAnother option: my $HEADER =3D "$ENV{DOCUMENT_ROOT}/header.s=
html"; ----- Original Message ----=0AFrom: Roberto C. S=E1nchez to@connexer.com>=0ATo: modperl@perl.apache.org=0ASent: Wednesday, February =
6, 2008 8:10:08 PM=0ASubject: Re: Question about open() =0AOn =0AWed, =
=0AFeb =0A06, =0A2008 =0Aat =0A10:06:05PM =0A-0500, =0AMag =0AGam =0Awrote:=
=0A> =0AHi =0AAll,=0A> =0A> =0AI =0Ahave =0Abeen =0Ausing =0Amod_perl, =0Aa=
nd =0AI =0Ahave =0Aseveral =0Aperl-cgi =0Afiles =0Athat =0Ause =0Athe=0A> =
=0Aopen(). =0AI =0Ause =0Athis =0Afunction =0Ato =0Aopen/include =0Amy =0Ah=
eader, =0Afooter, =0Abasically =0Aa=0A> =0Apoor =0Aman =0Atemplate =0Asyste=
m. =0ACurrently, =0Awhen =0AI =0Aopen =0Aa =0Afile =0AI =0Ahave =0Ato =0Aus=
e =0Athe=0A> =0Aabsolute =0Apath =0A(/var/www/appname/top.inc). =0AIs =0Ai=
t =0Apossible =0Afor =0Ame =0Ato =0Ause =0Ajust=0A> =0A'top.inc'? =0AI =0At=
hink =0Ait =0Atrying =0Ato =0Aread =0Afrom =0ADocumentRoot, =0Awhich =0Ais =
=0Acausing =0Athe=0A> =0Aissue. =0AHas =0Aanyone =0Aever =0Afaced =0Athis?=
=0A> =0AI =0Ajust =0Aset =0Asomething =0Alike =0Athis =0Ain =0Aglobal.asa:=
my =0A$base_dir = =0Acwd =0A. =0A'/'; Then =0AI =0Acan =0Am=
ake =0Athe =0A$base_dir =0Aavailable =0Aglobally =0Aand =0Ajust =0Ause =0At=
hat=0Aanywhere =0AI =0Aneed =0Ato =0Arefer =0Ato =0Aan =0Aon =0Adisk =0Afil=
e. Regards, -Roberto -- =0ARoberto =0AC. =0AS=E1nchez=0Ahttp=
://people.connexer.com/~roberto=0Ahttp://www.connexer.com=0A =0A=
____________________________________________________________ _________=
_______________=0ABe a better friend, newshound, and =0Aknow-it-all with Ya=
hoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=3DAhu06i62sR8HDtDy=
pao8Wcj9tAcJ =0A

Re: Question about open()

am 07.02.2008 21:45:23 von Perrin Harkins

On Feb 6, 2008 10:06 PM, Mag Gam wrote:
> Currently, when I open a file I have to use the
> absolute path (/var/www/appname/top.inc). Is it possible for me to use just
> 'top.inc'?

You can either use DocumentRoot
(http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.htm l#C_document_root_)
or use ModPerl::RegistryPreFork which will chdir to the directory your
script is in just like a normal CGI script does. That would let you
use files relative to the script.

- Perrin

Re: Question about open()

am 07.02.2008 23:14:12 von Chandrakumar Muthaiah

Perrin Harkins wrote:
> On Feb 6, 2008 10:06 PM, Mag Gam wrote:
>
>> Currently, when I open a file I have to use the
>> absolute path (/var/www/appname/top.inc). Is it possible for me to use just
>> 'top.inc'?
>>
>
> You can either use DocumentRoot
> (http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.htm l#C_document_root_)
> or use ModPerl::RegistryPreFork which will chdir to the directory your
> script is in just like a normal CGI script does. That would let you
> use files relative to the script.
>
> - Perrin
>

Few quirks with document root. Your application may not be hosted under
document root. you may have all your templates and customizations some
where else.

I think better option would be to define the template/support files
location in Directory Configuration or in a Database configuration
table. That would be more staple solution.

in your .htaccess or on the Location/Directory Configuration put a line
that says

PerlSetVar AppsSupportFiles "/home/httpd/support/site1/template"


and access this parameter from your $r->dir_config('AppsSupportFiles')


I think this may be more customizable and scalable solution to your problem

-Chandra

Re: Question about open()

am 10.02.2008 18:24:04 von Mag Gam

------=_Part_29075_18091215.1202664244128
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I am taking the Apache2::Request method, and will integrate the DB solution
as Chandra mentioned.



#!/usr/bin/perl -w
use strict;
use CGI;
use Apache2::Request;
use Data::Dumper;

print "Content-type: text/html\n\n";
my Apache2::Request $r = shift;
my $docroot = $r->document_root('/var/www/html/perl');
print $docroot;

For some reason, its still defaulting to /var/www/html. I need it to goto
/var/www/html/perl

Any thoughts?




On Feb 7, 2008 5:14 PM, Chandrakumar Muthaiah
wrote:

>
> Perrin Harkins wrote:
> > On Feb 6, 2008 10:06 PM, Mag Gam wrote:
> >
> >> Currently, when I open a file I have to use the
> >> absolute path (/var/www/appname/top.inc). Is it possible for me to use
> just
> >> 'top.inc'?
> >>
> >
> > You can either use DocumentRoot
> > (
> http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html #C_document_root_
> )
> > or use ModPerl::RegistryPreFork which will chdir to the directory your
> > script is in just like a normal CGI script does. That would let you
> > use files relative to the script.
> >
> > - Perrin
> >
>
> Few quirks with document root. Your application may not be hosted under
> document root. you may have all your templates and customizations some
> where else.
>
> I think better option would be to define the template/support files
> location in Directory Configuration or in a Database configuration
> table. That would be more staple solution.
>
> in your .htaccess or on the Location/Directory Configuration put a line
> that says
>
> PerlSetVar AppsSupportFiles "/home/httpd/support/site1/template"
>
>
> and access this parameter from your $r->dir_config('AppsSupportFiles')
>
>
> I think this may be more customizable and scalable solution to your
> problem
>
> -Chandra
>

------=_Part_29075_18091215.1202664244128
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I am taking the Apache2::Request method, and will integrate the DB solution as Chandra mentioned.

 

 

 

#!/usr/bin/perl -w
use strict;
use CGI;
use Apache2::Request;
use Data::Dumper;


print "Content-type: text/html\n\n";
my Apache2::Request $r = shift;
my $docroot = $r->document_root('/var/www/html/perl');

print $docroot;

 

For some reason, its still defaulting to /var/www/html. I need it to goto /var/www/html/perl

 

Any thoughts?


 


 

On Feb 7, 2008 5:14 PM, Chandrakumar Muthaiah <> wrote:





Perrin Harkins wrote:
> On Feb 6, 2008 10:06 PM, Mag Gam <> wrote:
>
>> Currently, when I open a file I have to use the

>> absolute  path (/var/www/appname/top.inc). Is it possible for me to use just
>> 'top.inc'?
>>
>
> You can either use DocumentRoot
> ()

> or use ModPerl::RegistryPreFork which will chdir to the directory your
> script is in just like a normal CGI script does.  That would let you
> use files relative to the script.
>
> - Perrin

>

Few quirks with document root. Your application may not be hosted under
document root. you may have all your templates and customizations some
where else.

I think better option would be to define the template/support files

location in Directory Configuration or in a Database configuration
table. That would be more staple solution.

in your .htaccess or on the Location/Directory Configuration put a line
that says

PerlSetVar AppsSupportFiles "/home/httpd/support/site1/template"



and access this parameter from your $r->dir_config('AppsSupportFiles')


I think this may be more customizable and scalable solution to your problem

-Chandra



------=_Part_29075_18091215.1202664244128--

Re: Question about open()

am 10.02.2008 18:32:33 von Perrin Harkins

On Feb 10, 2008 12:24 PM, Mag Gam wrote:
> my $docroot = $r->document_root('/var/www/html/perl');

Why are you trying to change the DocumentRoot?

- Perrin

Re: Question about open()

am 10.02.2008 18:37:32 von Mag Gam

------=_Part_29121_556670.1202665052872
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks for the quick response Perrin.

I am trying to change DocumentRoot because, currently I am using open() to
load templates for my website. I have header, menu, footer in 3 seperate
files, and I generate content like that. It works fine now, just not too
dynamic when I want to move the stuff around. I have
open("/var/www/perl/header.file") hardcoded, which is a pain. I just want
open ("header.file").

If I do open("header.file") its trying to read from DocumentRoot ie.
/var/www/header.inc, which does not exist.





On Feb 10, 2008 12:32 PM, Perrin Harkins wrote:

> On Feb 10, 2008 12:24 PM, Mag Gam wrote:
> > my $docroot = $r->document_root('/var/www/html/perl');
>
> Why are you trying to change the DocumentRoot?
>
> - Perrin
>

------=_Part_29121_556670.1202665052872
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks for the quick response Perrin.

 

I am trying to change DocumentRoot because, currently I am using open()  to load templates for my website. I have header, menu, footer in 3 seperate files, and I generate content like that. It works fine now, just not too dynamic when I want to move the stuff around. I have open("/var/www/perl/header.file") hardcoded, which is a pain. I just want open ("header.file").


 

If I do open("header.file") its trying to read from DocumentRoot ie. /var/www/header.inc, which does not exist.

 

 



 

On Feb 10, 2008 12:32 PM, Perrin Harkins <> wrote:


On Feb 10, 2008 12:24 PM, Mag Gam <> wrote:
> my $docroot = $r->document_root('/var/www/html/perl');

Why are you trying to change the DocumentRoot?


- Perrin



------=_Part_29121_556670.1202665052872--

Re: Question about open()

am 11.02.2008 02:58:30 von Foo JH

I do keep my templates in other directories also.

1. If your directories are relative to the document root, and you can
take advantage of this fact by rendering a variable to remember the
template path.
2. If your template directories have nothing in common with the document
root, then you can set the variable via SetPerlVar within http.conf.
That takes the 'hard' out of your code. :)




Mag Gam wrote:
> Thanks for the quick response Perrin.
>
> I am trying to change DocumentRoot because, currently I am using
> open() to load templates for my website. I have header, menu, footer
> in 3 seperate files, and I generate content like that. It works fine
> now, just not too dynamic when I want to move the stuff around. I have
> open("/var/www/perl/header.file") hardcoded, which is a pain. I just
> want open ("header.file").
>
> If I do open("header.file") its trying to read from DocumentRoot ie.
> /var/www/header.inc, which does not exist.
>
>
>
>
>
> On Feb 10, 2008 12:32 PM, Perrin Harkins > > wrote:
>
> On Feb 10, 2008 12:24 PM, Mag Gam > > wrote:
> > my $docroot = $r->document_root('/var/www/html/perl');
>
> Why are you trying to change the DocumentRoot?
>
> - Perrin
>
>

Re: Question about open()

am 11.02.2008 20:45:46 von Perrin Harkins

On Feb 10, 2008 12:37 PM, Mag Gam wrote:
> I am trying to change DocumentRoot because, currently I am using open() to
> load templates for my website. I have header, menu, footer in 3 seperate
> files, and I generate content like that. It works fine now, just not too
> dynamic when I want to move the stuff around. I have
> open("/var/www/perl/header.file") hardcoded, which is a pain. I just want
> open ("header.file").
>
> If I do open("header.file") its trying to read from DocumentRoot ie.
> /var/www/header.inc, which does not exist.

That's not related to DocumentRoot. The open() command opens files
relative to your current working directory. If you use
ModPerl::RegsitryPreFork, that will be the same directory your script
is in. Alternatively, you can chdir() to the directory you want.
What you're trying to do right now with DocumentRoot should be done
with chdir() instead.

- Perrin