use warnings; use strict; my $count = 1; my @test_characters = qw( * . " / \ [ ] : ; | ); push @test_characters, ' '; push @test_characters, ','; foreach my $char (@test_characters){ print "char = \'$char\'\n"; my $logfile = $0; $logfile =~ s/\.pl$/_$count-$char---\.log/; $count++; print "logfile = >$logfile<\n"; if(not open my $fh_log, ">", $logfile) { print "Error *** Couldn't open logfile for output: $logfile - $! : $^E ---\n",'-'x79,"\n"; next; } else { print "-- Opened logfile for output: $logfile ---\n"; if( not print $fh_log "-- Opened logfile for output: $logfile ---\n",'-'x79,"\n" ){ print "Couldn't print to file handle.$!--\n"; } print '-'x79,"\n"; } }