using references to point to sliding window array in Perl
问题 here is my problem: I have 2 arrays. One is character array and represents a sliding window. Characters gets shifted from the beginning and pushed at the end. I would like to use a second array to store references to array slices that 'follow' the characters as they move along. Example: my @char_array = ('h','e','l','l','o','w','o','r','l','d'); my $char_arr_ref=[@char_array[1..$#char_array]]; print @$char_arr_ref, "\n"; # slice contains 'elloworld'; shift(@char_array); push(@char_array), 'x'