Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Mini-Tutorial: Scalar vs List Assignment Operator

by ikegami (Pope)
on Aug 20, 2009 at 16:05 UTC ( #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
    # 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;
    
  6. or download this
    my $count = () = f();
    
  7. or download this
    # Prints @x.
    print(@x = @y);
    

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-09-18 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (109 votes), past polls