Help for this page

Select Code to Download


  1. or download this
    # in 5.005_02
    $x = (1,2,3)[10];  # $x is undef
    ...
    $x = (1,2,3)[10];  # $x is undef
    @x = (1,2,3)[10];  # @x is (), not (undef)
    @x = (undef)[0];   # @x is (undef), not ()
    
  2. or download this
    # returns the collapsed list: 15 chars
    #             123456789_12345
    ...
    # modifies array ref elements in place: 26 chars
    #             123456789_123456789_123456
    sub collapse {@$_=grep{defined}@{$_=pop}}