use strict; use warnings; my $count; my @array=(1,2,3); open(FILE,">/myfile.txt"); print FILE "$array[$count]\n"; close(FILE);