in reply to Re: Binary Comparision
in thread Binary Comparision

You're missing a call to binmode(),

The OP used :raw in the open, a suitable alternative.

#!perl -l open(my $fh, '<', $0); print(substr(<$fh>, -2) eq "\r\n" ?'bin':'txt'); # txt open(my $fh, '<', $0); binmode($fh); print(substr(<$fh>, -2) eq "\r\n" ?'bin':'txt'); # bin open(my $fh, '<', $0); binmode($fh, ':raw'); print(substr(<$fh>, -2) eq "\r\n" ?'bin':'txt'); # bin open(my $fh, '<:raw', $0); print(substr(<$fh>, -2) eq "\r\n" ?'bin':'txt'); # bin