Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Greetings all,

I want to remove a utf8 BOM from a .pl file. I can do it by using an another perl script to process the file like so:

while ( my $line = <IN> ) { $line =~ s/^\x{FEFF}//; print OUT $line;
But why can't I just do it like this in vim when editing the file itself?
s/^\x{FEFF}//g
That doesn't match the BOM. I'm a rookie, so maybe I'm making a rookie mistake.

Thanks, zod

UPDATE: Just for the sake of completeness if anyone wonders about this later: The BOM is not considered part of the text of the file you are editing in VIM. Vim strips the BOM when the file is opened and sets the local 'bomb' option to remember that it must be added back when writing the file. So you can't pattern match it because it isn't there while you have the file open in VIM. See here.


In reply to Remove BOM ? by zod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (11)
    As of 2014-08-21 16:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (136 votes), past polls