Use a scalar variable as our subscript:
#!/usr/bin/perl use warnings; use strict; my @array = (1, 3, 5, 7, 9); my $subscript = 3; print $array[$subscript], "\n"; $array[$subscript] = 12;