Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Easy detection of BOM

by mwhiting (Beadle)
on Jan 04, 2013 at 02:08 UTC ( #1011541=perlquestion: print w/ replies, xml ) Need Help??
mwhiting has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks. I have a script on a webserver where I need to detect the presence or absence of a BOM from the start of a datafile. I have an existing subroutine that opens the file and reads the first record just to find out how many fields it has, and I will be adding it there.

What's an easy way of doing this? I am wondering if File::BOM is the way to go, and from cpan.org I see it has this function:

use File::BOM open_bom(FH, $file) $encoding = get_encoding_from_filehandle(FH)

I know some people say not to bother with checking, but in this case I need to know for the purposes of later code.

Thanks!

Comment on Easy detection of BOM
Download Code
Re: Easy detection of BOM
by Anonymous Monk on Jan 04, 2013 at 03:08 UTC
Re: Easy detection of BOM
by Anonymous Monk on Jan 04, 2013 at 03:10 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011541]
Approved by LanX
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-10-01 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (18 votes), past polls