#!/usr/bin/perl

my @my_arr = ("test1", "test2", "test3", "test2", "test5", "test2", "test6");
my $what = 'test2';
my $then = 'best2';

foreach ( @my_arr ) {
	s/^$what$/$then/ and last;
}

print $_, "\n" for @my_arr;
