Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to run the following program to get pperl to run with more than 5 threads ... this works from the command line, but I need this to run from the script itself as this will be a cgi file eventually. Any ideas?
#!/usr/bin/pperl --prefork=25 print "\n\nHELLO\n";
OUTPUT:
Unrecognized switch: --prefork=25 (-h will show valid options). pperl: perl script failed to start: No such file or directory
Thanks

Replies are listed 'Best First'.
Re: Persistant Perl arguments ( pperl )
by mr_mischief (Monsignor) on Apr 28, 2008 at 17:38 UTC
    From the docs for PPerl:
    $ pperl <perl params> -- <pperl params> scriptname <script params>

    I think you need this:

    #!/usr/bin/perl -- --prefork 25 print "\n\nHELLO\n";

    You need to tell pperl that your perl options are through and your pperl options have started. The '--' by itself should do that.

    Update:

    Update 2: You're right, and I did run it accidentally as perl instead of pperl on the sheband line. When I try, I get the same thing you do. Yet /usr/local/bin/pperl --prefork=25 foo works from the command line, with a Perl program in file "foo". Perhaps PPerl just doesn't support working from the shebang line, and must be invoked on a program that's in a file.

      Thanks for the reply mischief, however your example uses "/usr/bin/perl" not "/usr/bin/pperl". Maybe I don't understand, but heres the scenario. This script will be called as a cgi file, so I can not run via the command line, but I still need to get that --prefork=25 option whenever apache hits the file. Your example uses /usr/bin/perl and just ignores the option. If I use your method with /usr/bin/pperl I get the following.
      #!/usr/bin/pperl -- --prefork=25 print "\n\nHELLO\n";
      Output:
      Can't open perl script "--prefork=25": No such file or directory pperl: perl script failed to start: No such file or directory
      Let me know if I'm not making any sense!
        On further examination, it looks like you can't use pperl properly from the shebang line. It appears to be intended to launch a separate program to be named on the command line only. See my update at Re: Persistant Perl arguments ( pperl ) for more info.
Re: Persistant Perl arguments ( pperl )
by Anonymous Monk on Apr 28, 2008 at 21:01 UTC
    So I found the solution to this issue ... use PerPerl instead of pperl. I ran into issues using CGI with pperl, and then issues with pperl throwing server 500 errors when too many users hit the script. I fixed the 500 errors (by clearing CGI's global variables out every run of the script) however I couldn't find out how to launch more than 5 threads to circumvent the 500 errors. Switching to PerPerl got around this with no configuration or options passed, it scales nicely.
Re: Persistant Perl arguments ( pperl )
by stiller (Friar) on Apr 28, 2008 at 16:49 UTC
    update2: I can only get it working with the default five preforked instances:
    #!/usr/bin/pperl # no options

    update: way off the mark, see mr_mischief under for solution
    #!/usr/bin/pperl --prefork 25 # ^--- no = </c>

      Tried that already, same issue. Is this a bug with pperl?
      #!/usr/bin/pperl --prefork 25 print "\n\nHELLO\n";
      Output:
      Unrecognized switch: --prefork (-h will show valid options). pperl: perl script failed to start: No such file or directory