"Mr. Shawn H. Corey" schreef:
> On Thu, 2008-08-21 at 21:55 -0700, Noah wrote:
>> Is there a way to simplify the following to one line?
>> my $value = $t1lsq{$interfaceName};
>> $value = 4 if $value > 4;
>
> Simple in a Rube Goldberg's kind of way ;)
> ( $value ) = sort { $a <=> $b }
An alternate version:
my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName};
and a test:
$ perl -le '
$t1lsq{$interfaceName}=2 ;
my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName};
print $value
'
2
$ perl -le '
$t1lsq{$interfaceName}=5 ;
my $value = ( $t1l
On Fri, 22 Aug 2008 07:15:49 -0700, John W. Krahn wrote:
> Peter Scott wrote:
>> my $value = max( 4, $t1lsq{$interfaceName} );
>
> s/max/min/
>
> :-)
Wow, they are different. Maybe that explains my overdraft...
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
--
To
Peter Scott wrote:
On Thu, 21 Aug 2008 21:55:46 -0700, Noah wrote:
Is there a way to simplify the following to one line?
my $value = $t1lsq{$interfaceName};
$value = 4 if $value > 4;
If you happen to already have
use List::Util qw(max);
in your code
On Thu, 21 Aug 2008 21:55:46 -0700, Noah wrote:
> Is there a way to simplify the following to one line?
>
> my $value = $t1lsq{$interfaceName};
> $value = 4 if $value > 4;
If you happen to already have
use List::Util qw(max);
in your code (or don't mind
Noah wrote:
>
> Is there a way to simplify the following to one line?
>
>
> ---
>
> my $value = $t1lsq{$interfaceName};
> $value = 4 if $value > 4;
I'm wondering why you want to do that?
Depending on your reasons, perhaps this would do?
my $value = $t1lsq{
On Thu, 2008-08-21 at 21:55 -0700, Noah wrote:
> Hi there,
>
> Is there a way to simplify the following to one line?
>
>
> ---
>
> my $value = $t1lsq{$interfaceName};
> $value = 4 if $value > 4;
>
>
>
>
>
Simple in a Rube Goldberg's kind of way ;)
(
Noah schreef:
> Is there a way to simplify the following to one line?
>
>my $value = $t1lsq{$interfaceName};
>$value = 4 if $value > 4;
Not really. You might not want to get $t1lsq{$interfaceName} twice,
because of side effects for example, one being that it is just slower to
do things tw
John W. Krahn wrote:
If you consider this to be simpler:
my $value = $t1lsq{ $interfaceName } > 4 ? 4 : $t1lsq{ $interfaceName };
Oh, yes, of course! Opps, ignore my suggested line of code... :-)
Ray
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PR
Noah wrote:
Hi there,
Hello,
Is there a way to simplify the following to one line?
my $value = $t1lsq{$interfaceName};
$value = 4 if $value > 4;
If you consider this to be simpler:
my $value = $t1lsq{ $interfaceName } > 4 ? 4 : $t1lsq{ $interfaceName };
John
--
Perl isn't a to
Hi Noah,
The ?: operator would do the trick:
http://www.perl.com/doc/manual/html/pod/perlop.html#Conditional_Operator
I think what you need would be this, but I haven't tried it:
(my $value > 4) ? ($value = 4) : ($value = $t1lsq{$interfaceName});
Ray
Noah wrote:
Hi there,
Is there a
11 matches
Mail list logo