Re: [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Be sure to wear flowers on your hat, Jakub!
2010/05/15 15:58:11 +0200 Jakub Narebski <jnareb@xxxxxxxxx> => To Peter Vereshagin :
===
JN> >       eval "use Image::Magick;";
JN> >       if ($@){
JN> > ===
JN> > 
JN> > are those lemmings wrong?
JN> 
JN> No they are not.

so that code is just right, and this:
===
eval( 'use Module;' ); die $@ if $@;
===

is 'Wrong!'. And what is the difference?

JN> would work as expected, I think that 'use' in conditional 'eval BLOCK' would
JN> not.

I think so too as I did never meant about eval BLOCK;

JN>   if (<condition>) {
JN>       eval { use Image::Magick; }
JN>       ...
JN>   }
JN> 
JN> So if you want to use 'eval BLOCK' form, you need to use 'require' and not
JN> 'use':
JN> 
JN>   if (<condition>) {
JN>       eval { require Image::Magick; import Image::Magick; }
JN>       ...
JN>   }
JN> 
JN> 
JN> Second, if you are not interested in error condition, and only whether
JN> require'ing some module failed or not, then instead of
JN> 
JN>   eval { require Net::SSLeay };
JN>   no_SSL_warning($URL) if $@;
JN> 
JN> you can use the 'eval { <sth>; 1 };' idiom, i.e.
JN> 
JN>   eval { require Net::SSLeay; 1; }
JN>       or no_SSL_warning($URL);

'eval BLOCK' versus 'eval EXPR' it's just better, but not a tabu. 'eval EXPR'
with $@ checking causes no any errors on the same runtime with the code to be
executed later.
For most cases the modules are used, the read/parsing error can be the only
error possible as no run-time code happens out there but only the symbols
declaration.
Therefore checking $@ is just fine.

JN> When I added checking for $@ in the form of 'die $@ if $@', the error that
JN> Perl shown was the syntax error in the foo() subroutine in $file file.

and this is where the $@ was sufficient, too.

JN> I don't know if it would be complete replacement for FCGI::Spawn, but from
JN> your description of it, using Plack::App::CGIBin middleware (+ plackup +
JN> Plack::Handler::FCGI wrapper) could be a valid alternative to it..

There are some more features those are on by default in FCGI::Spawn if they are
to be replaced, not sure if I will find them inside that framework.

JN> P.S. About Girocco: instead of writing it as set of separate CGI scripts, it
JN> could have been instead written as single app, loading its modules ('use
JN> lib' would help).

... and sharing them with gitweb, right. ;-)

73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)
-- 
http://vereshagin.org
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]