csorrentini has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
Just wondering if this would be the correct way to write a subroutine to see if a file is binary or text. It appears to run however when I changed the file it looks at to all zeros and ones it still showed up with Text file? Any advice?
sub type {
if (-T $FileInfoName) {
return "Text file";
}
elsif (-B $FileInfoName) {
return "Binary file"
}
}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Trying to write a subroutine to return if file is Text or Binary
by GrandFather (Saint) on Jun 26, 2014 at 03:21 UTC | |
Re: Trying to write a subroutine to return if file is Text or Binary
by nevdka (Pilgrim) on Jun 26, 2014 at 05:13 UTC | |
Re: Trying to write a subroutine to return if file is Text or Binary
by DrHyde (Prior) on Jun 26, 2014 at 10:25 UTC | |
by csorrentini (Acolyte) on Jun 26, 2014 at 17:05 UTC | |
by DrHyde (Prior) on Jul 02, 2014 at 10:14 UTC | |
Re: Trying to write a subroutine to return if file is Text or Binary
by Laurent_R (Canon) on Jun 26, 2014 at 06:07 UTC | |
Re: Trying to write a subroutine to return if file is Text or Binary
by pvaldes (Chaplain) on Jun 30, 2014 at 23:01 UTC |
Back to
Seekers of Perl Wisdom