Just another Perl shrine | |
PerlMonks |
Question regarding a regexby CrashBlossom (Beadle) |
on Jul 22, 2021 at 18:34 UTC ( [id://11135314]=perlquestion: print w/replies, xml ) | Need Help?? |
CrashBlossom has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I would like some help in understanding the regular expression in the following code: It attempts to guess whether a file is a text file based on what it sees in the first 4096 characters. I ran across it while seeking an alternative to -T to check for a text file. It seems to work in my tests, but I don't understand why because I don't understand what the regex is matching. My understanding is that [] defines a character class. A ^ before [] means negation. * means zero or more. $ means end of line. So if I put that all together, it seems to mean that is true if $block does nor include any of \r\n\t -~ before an end of line. But that doesn't make sense. I'm also mystified by the inclusion of the characters -~ in the character class. Can anyone unpack all this for me? I am running strawberry perl 5.30 on windows 10. Thanks!
Back to
Seekers of Perl Wisdom
|
|