There is nothing wrong with your logic. If you had used strict and warnings, you would have received an error message referring to the offending statement. (Your print statement is trying to print back to the input file.)

I have replaced your disk file with an in-memory file in order to show the data in the post.

Code

C:\Users\Bill\forums\guru>type tsdjim0.pl my $random_file = \<<'END_RANDOM_FILE'; Auguststart Some text some more text Augustend Septemberstart Some text some more text Septemberend END_RANDOM_FILE my ( $day, $month, $year ) = ( localtime )[3,4,5]; $month = ( qw/ January February March April May June July August September October November December / )[$month];