Removing BOM from UTF-8

Gerard Seibert gerard at
Sat Feb 18 11:35:10 PST 2006

Benjamin A'Lee wrote:

> On Sat, 2006-02-18 at 11:28 -0500, Gerard Seibert wrote:
> > It has been suggested that a script could be written to eliminate
> > the BOM from a file(s). My script writing skills suck. I have been
> > unable to locate one using Google, so I was hoping that someone
> > might know where I could either locate such a program, or perhaps
> > give me an idea on how to script one.
> #!/usr/bin/perl
> @file=<>;
> $file[0] =~ s/^\xEF\xBB\xBF//;
> print(@file);
> That'll read a file from stdin, remove the BOM from the beginning of
> the first line if it's present, and print it to stdout.
> Hope it helps.
>     Ben
> --
> Termisoc Tech Officer: <>
> My Homepage: <>
> "People demand freedom of speech as compensation for the freedom of
> thought which they have but seldom use." -- Søren Kierkegaard

Maybe I am doing something wrong, but it does not appear to be working 
correctly. I named the file and put it in the same directory 
as the files I want to convert. I also set the program permission to 

typing the p[program name does nothing; I have to precede it with 
'perl'. Even then, it does not appear to work correctly. In the 
following example, the file is parsed, but not converted.

perl testfile

Am I doing something incorrectly here?


Gerard Seibert
gerard at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list