Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: include statement in perl?

by Zaxo (Archbishop)
on May 31, 2003 at 02:46 UTC ( [id://262016]=note: print w/replies, xml ) Need Help??


in reply to include statement in perl?

This is not specific to CGI.pm

sub include { my $file = shift; open my $fh, '<', $ENV{'DOCUMENT_ROOT'}.$file or return; while (<$fh>) { print } close $fh or return; return 1; }
Taint mode will require that you set $ENV{'DOCUMENT_ROOT'} for yourself.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: include statement in perl? (DOCUMENT_ROOT trustworthy)
by Aristotle (Chancellor) on May 31, 2003 at 03:15 UTC
    It should be noted that as DOCUMENT_ROOT is set by the webserver and not subject to user input, it's safe to trust.

    Makeshifts last the longest.

      'safe to trust' ne 'untainted' :)

      Greetz
      Beatnik
      ... I'm belgian but I don't play one on TV.
        Of course; I just mean you don't need to set it yourself. It'll suffice to simply do something like
        my ($doc_root) = $ENV{DOCUMENT_ROOT} =~ /(.*)/;

        Makeshifts last the longest.

Re: Re: include statement in perl?
by stonecolddevin (Parson) on May 31, 2003 at 03:42 UTC
    Ohhh, so you basically just open up the file, read it, and then print it out? That sounds easy enough.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://262016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found