Re: need help in tutorial(alpha)
- From: muppet <scott asofyet org>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Re: need help in tutorial(alpha)
- Date: Wed, 17 May 2006 23:34:24 -0400
On May 17, 2006, at 9:41 PM, A. Pagaltzis wrote:
* Mat Wilson <mat jnm com au> [2006-05-18 03:10]:
# We do not have a Glib::CLAMP function, so we provide it
here.
sub clamp ($val, $low, $high)
That is a syntax error in Perl.
{
return (($val > $high) ? $high : (($val < $low) ? $low :
$val));
}
use List::Util qw( min max );
# ...
return min $low, max $high, $val;
Or just
sub clamp ($$$)
{
my ($val, $low, $high) = _;
return (($val > $high) ? $high : (($val < $low) > $low :
$val));
}
See the "Prototypes" section in the perlsub manpage for more
information.
--
"There's a documentary that i wanted to watch on PBS. I heard about
it in NPR. ... Oh my god, did i just say that?"
-- elysse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]