[pm-h] July Meeting

Todd Rinaldo toddr at null.net
Tue Jul 22 10:28:00 PDT 2008


can I do $value = shift ||= "Default value"
?

On Tue, Jul 22, 2008 at 9:36 AM, Robert Boone <robo4288 at gmail.com> wrote:
>
> The short cut for if(!defined $value); is a perl 5.10/6 feature:
>     $value //= "some sorta default";
>
> The other is good in all perl 5 version and lower, I think:
>    $value = "some sorta default" if(!$value);
>    becomes
>    $value ||= "some sorta default";
>
>
> On Jul 22, 2008, at 9:31 AM, Todd Rinaldo wrote:
>
>> ok so someone explain these operators, cause obviously I shoulda read
>> the whole camel book!
>>
>> Here is what I've always had to do the hard way. what's the simpler?
>>
>> I often do this
>> sub foo {
>>  my $value = shift;
>>  $value = "some sorta default" if(!defined $value);
>>
>> }
>>
>> Of course sometimes I want to do the permutation:
>>
>> sub bar {
>>  my $value = shift;
>>  $value = "some sorta default" if(!$value);
>>
>> }
>>
>> is there a simpler way?
>> _______________________________________________
>> Houston mailing list
>> Houston at pm.org
>> http://mail.pm.org/mailman/listinfo/houston
>> Website: http://houston.pm.org/
>
>
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/
>



-- 
Todd Rinaldo
toddr at null.net


More information about the Houston mailing list