Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Getting File Type using Regular Expressions

by Anonymous Monk
on Apr 21, 2004 at 17:12 UTC ( #347065=note: print w/replies, xml ) Need Help??


in reply to Re: Getting File Type using Regular Expressions
in thread Getting File Type using Regular Expressions

It is funny, out of that entire post I did not see a valid recommendation at all. All I saw was bashing of others recomendations.

An easy (but not fool proof) way of distinguishing between a text file or a binary file is use the ready-made -B file check operator. Or the -T (depending on which way your flag flies).

print "File is binary\n" if (-B); print "File is a text file\n" if (-T);
or if you are a "NOT" guy/girl the following might suit your fancy.
print "File is binary\n" if (!-T); print "File is a text file\n" if (!-B);
Hope that helps some.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://347065]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2019-08-21 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?