Warning:The following script is based on your first definition of HOSTS.TXT. You would have to use a split or other means to extract the host name if your HOSTS.TXT is actually as in your second definition.
In fact the second part is rather unclear - perhaps you could provide an exact explanation of what is in your files and what you wish to achieve?
#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI ':standard'; open MAINFILE, "../test/MAINFILE.TXT" or die $!; my @all = <MAINFILE>; close MAINFILE; open HOST, "../test/HOSTS.TXT" or die $!; foreach my $line (<HOST>) { chomp $line; open HOSTFILE, "> ../test/results/MAINFILE_$line.txt" or die $!; print HOSTFILE "@all"; close HOSTFILE; } close HOST; print "Content-type: text/html\n\n"; print "done";
In reply to Re: Can I copy a file and rename the file to many new files?
by jonnyfolk
in thread Can I copy a file and rename the file to many new files?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |