in reply to Interesting Mistake

What is my mistake doing?
In addition to what cdarke said, you should use strict and warnings, which would warn you that something is wrong.

=~ is one of the Binding Operators, but = ~ are two separate operators (= and ~). You are assigning the value of the ~m/IDX/gi to the $file variable. Since the assignment succeeds, you print the variable's value.