Your map returns a list of file names, but you assign it to a scalar.
That's not technically possible. The map is not returning a list, if it's being used in a scalar context. It just happens that if a map is used in a scalar context, it returns the number of items it
would have created had it been used as a list. But it just as easily could return the day of the year instead (although not quite as useful).
I know it may not sound like that's an important difference, but it's really important to understand that you don't ever get a list in a scalar context: in a scalar context, you get whatever the operation is defined to do in a scalar context instead. See On Scalar Context for more details.