in reply to creating a text file at run time and writing to it.

I'd probably do this:
#!/usr/bin/perl use strict; use warnings; open( NAMES, "<", "name.txt") or die $!; my @list = <NAMES>; close(NAMES); print "list = @list\n"; for my $name (@list) { open(OUT, ">", $name) or die $!; print OUT "hello"; close(OUT); }
Notice the differences:
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
Start with "use strict" and "use warnings" and that will be very helpful!
hth, dave

Update: Oops, forgot the .txt part - see madtoperl's node.

Replies are listed 'Best First'.
Re^2: creating a text file at run time and writing to it.
by Anonymous Monk on Jul 20, 2006 at 11:33 UTC
    Hi Thank you for the response but gives mesg " invalid argument" at line 11
    A reply falls below the community's threshold of quality. You may see it by logging in.