Help for this page

Select Code to Download


  1. or download this
    perl -le '@l = 1..5; @s = map{last if $_==4;++$_} @l;print "@s"'
    Can't "last" outside a loop block at -e line 1.
    
    perl -le '@l = 1..5; @s = map{return if $_==4;++$_} @l;print "@s"'
    Can't return outside a subroutine at -e line 1.
    
  2. or download this
    perl -le 'for(1) {@l = 1..5; @s = map {last if $_==4;++$_} @l} print "
    +@s"'
    
  3. or download this
    perl -le '@n = do { {@l = 1..5; @s = map {last if $_==4; "${_}a"} @l} 
    +}; print "qw(@s)\nqw(@n)"'
    qw()
    qw(1a 2a 3a 4 5)