Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Thoughts on some new operators for perl (6 or 7)

by Roy Johnson (Monsignor)
on Mar 10, 2004 at 18:24 UTC ( #335547=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # syntax
    lvalue ?= op value;
    ...
    $highest ?= lt substr($_, 10, 5);
    # ex: $foo ||= $bar, using the generalized ?= operator
    $foo ?= || $bar;
    
  2. or download this
    # ex: $foo = $default if !defined($foo)
    $foo ?= !defined $default;
    # ex: $foo{'bar'} = $default if exists($foo{'bar'})
    # That is, we're resetting the value, but not creating it
    $foo{'bar'} ?= exists $default;
    
  3. or download this
    # $foo = uc($foo)
    $foo ?= uc;
    # even do arrays!
    @arr ?= reverse;
    
  4. or download this
    # $foo = 5 if -$foo?
    # $foo = $foo - 5 if $foo - 5?
    $foo ?= - 5;
    
  5. or download this
    $foo{$bar}{$baz} ?= -;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://335547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-09-20 06:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (155 votes), past polls