#!/usr/bin/perl use strict; # split-logfiles # you don't need to test if it is open #$isopen = 0; my $myfile = "/var/tmp/test.log"; # no reason to do this testing # unless($isopen and -f $myfile) { # open the happy file here, but you may want to use >> if # you need to append rather then overwrite on each run open MYHAPPYFILE, ">$myfile" or die "Error opening $myfile"; # don't need to test if it is open because we # are dying if it isn't # $isopen = 1; # } while (my $log_file = ) { printf MYHAPPYFILE "%s", $log_line; } exit 0; #### #!/usr/bin/perl use strict; my $myfile = "/var/tmp/test.log"; open MYHAPPYFILE, ">$myfile" or die "Error opening $myfile"; while (my $log_file = ) { printf MYHAPPYFILE "%s", $log_line; } exit 0;