<?xml version="1.0" encoding="windows-1252"?>
<node id="1011541" title="Easy detection of BOM" created="2013-01-03 21:08:23" updated="2013-01-03 21:08:23">
<type id="115">
perlquestion</type>
<author id="326592">
mwhiting</author>
<data>
<field name="doctext">
&lt;p&gt;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.  
&lt;p&gt;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:

&lt;code&gt;use File::BOM
open_bom(FH, $file)
$encoding = get_encoding_from_filehandle(FH)
&lt;/code&gt;

&lt;p&gt;I know some people say not to bother with checking, but in this case I need to know for the purposes of later code.
&lt;p&gt;Thanks!</field>
</data>
</node>
