#!/usr/bin/perl use strict; use warnings; open( NAMES, "<", "name.txt") or die $!; my @list = ; close(NAMES); print "list = @list\n"; for my $name (@list) { open(OUT, ">", $name) or die $!; print OUT "hello"; close(OUT); } #### 1. use strict and use warnings; 2. use the "$!" so you get the explicit error when there is one 3. you didn't define $y - and it looks to be unnecessary for this 4. you didn't close the FILE handles 5. you need to specify the FILE handle you want to write to