my $date =`/bin/date +'%m%d%y'`; chomp $date; my $LOG = "log.$date"; # another way to do that is to use perl internals instead of a sub-shell: { my ($d,$m,$y)=(localtime)[3..5]; my $perldate = sprintf "%02d%02d%02d", $m+1, $d, $y-100; die "This should never happen: $perldate != $date" if $perldate ne $date; } #### while () { next unless ( /FREEZING media id (.*)/ ); print "I am FREEZING $1\n"; }