$fruits = "apple,banana,grape,orange"; @fruits = split ',',$fruits; # last three elements of the array @last3 = @fruits[$#fruits-2..$#fruits]; print join(',',@last3),"\n";