Running external programs is done with open, system, exec, or "backticks" (the qx// operator). You can save some file manipulations if you don't write an intermediate file and then rename and modify it. User input can be read from STDIN. Here's a sketch,
for (1..25) {
warn "File Exists: $_.txt\n" and next if -f "$_.txt";
print 'My prompt message: ';
chomp(my $input = <STDIN>);
open my $fh, '>', "$_.txt" or warn $! and next;
open my $ph, '-|', $cmd, $input or warn $! and next;
{
local $_;
while {<$ph>) {
do_your_processing($_);
print $fh $_ or die $!;
}
}
}
You should see that this needs to be fleshed out by all your unspecified requirements.
|