No, the caret only negates the character set if it appears immediately after the left square bracket. Outside square brackets, it matches the beginning of the string or immediately after a newline. Also: the -~ sequence inside square brackets means 'any character between space and tilde, inclusive.'
So in words, the regular expression specifies 'all characters in the first 4096 (or end-of-file, whichever comes first) are "\r", "\n", "\t", or characters in the range space to tilde, inclusive, in your machine's native encoding'.
Off-topic comments:
- The -T operator will tell you if your file is ASCII/UTF-8. Just say return -T $_[0];.
- The special file handle _ (i.e. underscore) means "whatever file was last tested" under any recent Perl, and can be faster because it makes use of the same stat() structure.
- The three-argument form of open() is preferred because it handles file names with strange characters better. In your case it would be open FH, "<", $_[0]
- You should probably ensure that your open() succeeded. Something like open FH, "<", $_[0] or die "Failed to open $_[0]: $!"; is the usual idiom.
- People usually use lexical file handles rather than bareword file handles these days because they get closed automatically when they go out of scope (say, if you throw an unexpected exception). In your code that would look like open my $fh, "<", $_[0] ....