http://qs321.pair.com?node_id=11121466


in reply to Manipulating Array Indexes

What do you need an array for? Just use the string of data values you showed us.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121442 use warnings; my $data = '1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,'; my $target = 5; print $data =~ /\b$target,((?:\d+,){3})/g, "\n";

Outputs:

6,7,8,4,3,2,