Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Mini-Tutorial: Scalar vs List Assignment Operator

by ikegami (Patriarch)
on Aug 20, 2009 at 16:05 UTC ( [id://790129]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # @array evaluated in scalar context.
    my $count = @array;
    
  2. or download this
    # The s/// operates on $copy.
    (my $copy = $str) =~ s/\\/\\\\/g;
    
  3. or download this
    # Prints $x.
    print($x = $y);
    
  4. or download this
    # @array evaluated in list context.
    my @copy = @array;
    
  5. or download this
    # @array evaluated in list context.
    my ($first) = @array;
    
  6. or download this
    # Only dies if f() returns an empty list.
    # This does not die if f() returns a
    # false scalar like zero or undef.
    my ($x) = f() or die;
    
  7. or download this
    my $count = () = f();
    
  8. or download this
    # Prints @x.
    print(@x = @y);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://790129]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-03-19 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found