Should I migrate from CGI::Fast to something else in light of's deprecated status and how should I do so?

  • A+

I am using CGI::Fast to leverage the speed and scalability of FastCGI, and I also's query string parsing. I do not use's deprecated HTML writing functions.

Stopping the use of is strongly advised in the community, but in my use case, should I also be thinking of migrating away? And if so, how do I

1) still leverage FastCGI

2) grab query params

...without adopting a framework like Dancer or Mojolicious?

The code I am looking at replacing is just:

 while ( $main::cgi = new CGI::Fast ) {       my $name = $main::cgi->param('name');  } 

I am open to using something like CGI::PSGI in conjunction with Plack::Request, but I couldn't see how to finesse the FastCGI functionality as CGI::Fast and CGI::PSGI both want to subclass CGI for the creation of the object. And I'd still have in the mix to enable CGI::Fast. Plack seems like a lot to learn to replace what is now a few lines of code.


This neatly illustrates one reason why PSGI is an improvement on CGI (and its related technologies like FastCGI). In CGI-style programs, the code is tightly coupled with the deployment method and when you change the deployment method, you usually need to make quite large changes to the code. With PSGI-style programs, the code is the same no matter how you deploy it.

You haven't shown us any of your code, but you talk about "a few lines of code". So here's the approach I'd take.

  1. Rip all FastCGI-specific code out of your program - leaving a pure CGI-style program.
  2. You then have a choice. You could use the techniques I describe in Easy PSGI to convert your program to a pure PSGI program. Or, if that's going to be too much work, use CGI::PSGI to run your CGI program in a PSGI environment.
  3. You now have a PSGI program that you can use in pretty much any web server environment. You can serve it as a CGI program. You can use Plack::Handler::FCGI to run it under FCGI. Or you can deploy it as a standalone service behind a web proxy (that last option is the one I'd choose).

But any choice you make at step 3 isn't irrevocable. The same code will work in all deployment environments. And, therefore, moving between them is usually pretty simple.

p.s. isn't exactly deprecated. It has been removed from the standard Perl distribution but that's because its use is discouraged.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: