Help for this page

Select Code to Download


  1. or download this
    @data[ @ordered[ 0, -1 ] ] = @data[ @ordered[ -1, 0 ] ];
    
  2. or download this
    @data.setSlice( 
        items_to_set  => [ @ordered.getSlice( 0, @ordered.last ) ],
        values_to_set => [ @data.getSlice( @ordered.getSlice( @ordered.las
    +t, 0 ) ],
    );
    
  3. or download this
    ## an empty slice at runtime
    c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ grep $_ == 10, 1.
    +.9 ];"
    ## no output and no errors
    
  4. or download this
    ## an empty slice at compile time
    c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ ];"
    Scalar value @a[ ] better written as $a[ ] at -e line 1.
    syntax error at -e line 1, near "[ ]"
    Execution of -e aborted due to compilation errors.
    
  5. or download this
    ## a slice of one element at runtime
    c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ grep $_ == 5, 1..
    +9 ];"
    f
    
  6. or download this
    ## a slice of one element at compile time
    c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ 5 ];"
    Scalar value @a[ 5 ] better written as $a[ 5 ] at -e line 1.
    f