Perl CGI charset magic thingy (was: How to be an expert)
Ben Scott
dragonhawk at gmail.com
Tue Jun 13 09:32:01 EDT 2006
On 6/13/06, Ken D'Ambrosio <ken at proximatech.net> wrote:
> Speaking about being ignorant, I *think* I understand what the following
> line does...
> ... but, if so, then I don't understand why. Anyone care to give
> me their interpretation? [From /usr/share/perl5/Bugzilla/CGI.pm]
>
> $self->charset(Param('utf8') ? 'UTF-8' : '');
Well, that looks like the ternary operator (conditional expression).
To break it out:
if ($self->charsetParam('utf8')) {
return "UTF-8";
}
else {
return ""; # empty string
}
(Syntax may be slightly wrong, my Perl's a tad rusty.)
As for why, I suspect that depends on the context.
-- Ben
More information about the gnhlug-discuss
mailing list