Perl way to do PHP includes?

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Perl way to do PHP includes?

    Are the following Perl/PHP methods roughly equivalent in function and
    efficiencey?

    1. use Perl_package;
    require_once(file.php);

    2. open FILE, "< $perl_file";
    include(file.php);

    I'm trying to determine whether Perl/CGI.pm (no Embperl, Mason etc.) is
    sufficient for converting PHP scripts without incurring serious inefficiencies.

    Regards

    Garry Heaton


    Garry Heaton Guest

  2. Similar Questions and Discussions

    1. PHP Includes
      Hello, I am installing coppermine photo gallery on my site. I think I am running into problems - I get the following error message after...
    2. PHP includes in DW Mx
      I have just built a site and used php includes for the menu, for some reason when I am in design view it totally screws the page up and I am unable...
    3. Bogus error messages re Perl/lib/CORE/ includes
      Hi, Every now and then I get errors like the following when trying to compile a perl extension (perl 5.8, Win32): ...
    4. Help w/ Includes & CSS
      for some reason after I upgraded from MX 2004 to DreamWeaver 8, my site doesn't doesn't format with the style sheet i used previously in 2004. Also...
    5. XP includes ???????
      ah, ok, thanks
  3. #2

    Default Re: Perl way to do PHP includes?

    Garry Heaton <none@none.com> writes:
    > Are the following Perl/PHP methods roughly equivalent in function and
    > efficiencey?
    >
    > 1. use Perl_package;
    > require_once(file.php);
    Vaguely. You should read the perlmod docs ('perldoc perlmod') to find
    out exactly how this works. PHP just reads in the file and defines
    all the functions in it in the global namespace; Perl lets you be more
    fine-grained if you choose.
    > 2. open FILE, "< $perl_file";
    > include(file.php);
    Not even close. Did you read the Perl docs for open() to see what it
    does?
    > I'm trying to determine whether Perl/CGI.pm (no Embperl, Mason etc.) is
    > sufficient for converting PHP scripts without incurring serious inefficiencies.
    The question to be sure you've answered is why convert them if they're
    working now? Assuming you have a good reason, then it's best to have
    a good understanding of both languages. perldoc perlbook for more
    details about learning Perl.

    -=Eric
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
    Eric Schwartz Guest

  4. #3

    Default Re: Perl way to do PHP includes?


    Eric Schwartz wrote:
    > Garry Heaton <none@none.com> writes:
    >
    >>Are the following Perl/PHP methods roughly equivalent in function and
    >>efficiencey?
    >>
    >>1. use Perl_package;
    >> require_once(file.php);
    >
    >
    > Vaguely. You should read the perlmod docs ('perldoc perlmod') to find
    > out exactly how this works. PHP just reads in the file and defines
    > all the functions in it in the global namespace; Perl lets you be more
    > fine-grained if you choose.
    >
    >
    >>2. open FILE, "< $perl_file";
    >> include(file.php);
    >
    >
    > Not even close. Did you read the Perl docs for open() to see what it
    > does?
    >
    >
    >>I'm trying to determine whether Perl/CGI.pm (no Embperl, Mason etc.) is
    >>sufficient for converting PHP scripts without incurring serious inefficiencies.
    >
    >
    > The question to be sure you've answered is why convert them if they're
    > working now? Assuming you have a good reason, then it's best to have
    > a good understanding of both languages. perldoc perlbook for more
    > details about learning Perl.
    >
    > -=Eric
    Sorry, should have followed-up:

    2. open FILE, "< $perl_file";
    while (<FILE>) {
    print;
    };

    Garry

    Garry Heaton Guest

  5. #4

    Default Re: Perl way to do PHP includes?

    Garry Heaton wrote:
    > Eric Schwartz wrote:
    >
    >>Garry Heaton <none@none.com> writes:
    >>
    >>
    >>>Are the following Perl/PHP methods roughly equivalent in function and
    >>>efficiencey?
    >>>
    >>>1. use Perl_package;
    >>> require_once(file.php);
    >>
    >>
    >>Vaguely. You should read the perlmod docs ('perldoc perlmod') to find
    >>out exactly how this works. PHP just reads in the file and defines
    >>all the functions in it in the global namespace; Perl lets you be more
    >>fine-grained if you choose.
    >>
    >>
    >>
    >>>2. open FILE, "< $perl_file";
    >>> include(file.php);
    >>
    >>
    >>Not even close. Did you read the Perl docs for open() to see what it
    >>does?
    >>
    >>
    >>
    >>>I'm trying to determine whether Perl/CGI.pm (no Embperl, Mason etc.) is
    >>>sufficient for converting PHP scripts without incurring serious inefficiencies.
    >>
    >>
    >>The question to be sure you've answered is why convert them if they're
    >>working now? Assuming you have a good reason, then it's best to have
    >>a good understanding of both languages. perldoc perlbook for more
    >>details about learning Perl.
    >>
    >>-=Eric
    >
    >
    > Sorry, should have followed-up:
    >
    > 2. open FILE, "< $perl_file";
    > while (<FILE>) {
    > print;
    > };
    >
    > Garry
    >
    Or maybe even:

    2. open FILE, "< $perl_file";
    while (<FILE>) {
    print;
    }

    Garry


    Garry Heaton Guest

  6. #5

    Default Re: Perl way to do PHP includes?

    Garry Heaton <none@none.com> wrote:
    > 2. open FILE, "< $perl_file";

    You should always, yes *always*, check the return value from open():

    open FILE, $perl_file or die "could not open '$perl_file' $!";


    --
    Tad McClellan SGML consulting
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  7. #6

    Default Re: Perl way to do PHP includes?

    Garry Heaton <none@none.com> writes:
    > Garry Heaton wrote:
    >> Sorry, should have followed-up:
    >>
    >> 2. open FILE, "< $perl_file";
    >> while (<FILE>) {
    >> print;
    >> };
    >>
    >> Garry
    >>
    >
    > Or maybe even:
    >
    > 2. open FILE, "< $perl_file";
    > while (<FILE>) {
    > print;
    > }
    These are still completely different from include('file.php') in PHP.
    It might not hurt to read the PHP docs to understand what include()
    does, and why it's not the same thing as what you just printed above.

    -=Eric
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
    Eric Schwartz Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139