public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Peter Vereshagin <peter@vereshagin•org>
To: Jakub Narebski <jnareb@gmail•com>
Cc: Petr Baudis <pasky@suse•cz>, Eric Wong <normalperson@yhbt•net>,
	git@vger•kernel.org, Sam Vilain <sam.vilain@catalyst•net.nz>,
	Juan Jose Comellas <juanjo@comellas•org>,
	John Goerzen <jgoerzen@complete•org>
Subject: Re: [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script
Date: Sun, 16 May 2010 14:15:28 +0400	[thread overview]
Message-ID: <20100516101528.GA5761@screwed.box> (raw)
In-Reply-To: <201005151558.12191.jnareb@gmail.com>

Be sure to wear flowers on your hat, Jakub!
2010/05/15 15:58:11 +0200 Jakub Narebski <jnareb@gmail•com> => 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

  reply	other threads:[~2010-05-16 10:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07 12:54 [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script Jakub Narebski
2010-05-07 12:54 ` [PATCH/RFC 1/2] gitweb: Put all per-connection code in run() subroutine Jakub Narebski
2010-05-07 12:54 ` [RFC/PATCH 2/2] gitweb: Add support for FastCGI, using CGI::Fast Jakub Narebski
2010-05-08  7:59   ` [RFC/PATCHv2 " Jakub Narebski
2010-05-08 22:41 ` [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script Jakub Narebski
2010-05-09  9:31   ` Eric Wong
2010-05-09 11:48     ` Ævar Arnfjörð Bjarmason
2010-05-09 12:39     ` Jakub Narebski
2010-05-09 16:47       ` Peter Vereshagin
2010-05-09 18:18         ` Jakub Narebski
2010-05-10  7:13           ` Peter Vereshagin
2010-05-10 15:29             ` Jakub Narebski
2010-05-11  6:24               ` Peter Vereshagin
2010-05-11  8:35                 ` Petr Baudis
2010-05-11 10:58                 ` Jakub Narebski
2010-05-11 12:09                   ` Peter Vereshagin
2010-05-11 13:51                     ` Jakub Narebski
2010-05-13 13:10                       ` Peter Vereshagin
2010-05-13 17:13                         ` Ævar Arnfjörð Bjarmason
2010-05-14 15:58                           ` Peter Vereshagin
2010-05-14 10:53                         ` Jakub Narebski
2010-05-14 15:36                           ` Peter Vereshagin
2010-05-14 17:58                             ` Jakub Narebski
2010-05-14 18:43                               ` Jakub Narebski
2010-05-15 10:06                               ` Peter Vereshagin
2010-05-15 13:58                                 ` Jakub Narebski
2010-05-16 10:15                                   ` Peter Vereshagin [this message]
2010-05-18  1:06                                     ` Jakub Narebski
2010-05-16 10:26                                   ` Petr Baudis
2010-05-15 11:51                           ` Petr Baudis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100516101528.GA5761@screwed.box \
    --to=peter@vereshagin$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=jgoerzen@complete$(echo .)org \
    --cc=jnareb@gmail$(echo .)com \
    --cc=juanjo@comellas$(echo .)org \
    --cc=normalperson@yhbt$(echo .)net \
    --cc=pasky@suse$(echo .)cz \
    --cc=sam.vilain@catalyst$(echo .)net.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox