in reply to A better regex

As others have suggested better regexes Iam not going to ponder over what is a better regex. Read the following rule , and then browse through the code that you and others have posted.

You should always check for the success of a regex match before capturing the value in $1..$n

If the regex match fails you will end up having undefined value or some junk in $1. Always check for the success before you assign the captured values.

Your code should look like

if ( $zipfile =~ m/[AB]FILE_(\d+)/ ) { $day = $1; } else { # oops.. the file name is not what we expected .. # panic !! }

Hope this helps

-T