Date: Fri, 9 Oct 2009 19:01:09 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: wblock@wonkity.com (Warren Block) Cc: freebsd-questions@freebsd.org Subject: Re: for perl wizards. Message-ID: <200910091701.n99H19sq028830@lurza.secnetix.de> In-Reply-To: <alpine.BSF.2.00.0910090731450.28005@wonkity.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Warren Block wrote: > Oliver Fromme wrote: > > Gary Kline wrote: > > > > > > Whenever I save a wordpeocessoe file [OOo, say] into a > > > text file, I get a slew of hex codes to indicate the char to be > > > used. I'm looking for a perl one-liner or script to translate > > > hex back into ', ", -- [that's a dash), and so forth. Why does > > > this fail to trans the hex code to an apostrophe? > > > > > > perl -pi.bak -e 's/\xe2\x80\x99/'/g' > > > > You need to escape the inner quote character, of course. > > I think sed is better suited for this task than perl. > > That's twice now people have suggested sed instead of perl. Why? For > many uses, perl is a better sed than sed. The regex engine is far more > powerful and escapes are much simpler. Neither powerful regexes nor escapes will help in this case. A simple basic regex is more than sufficient (in fact this isn't even a regex, it's a fixed string). And the escaping is a problem of the shell, not perl or sed. And by the way, I stongly disagree that perl's escapes are much simpler. In my opinion perl has the most complex escaping and quoting I have seen in any language so far. The basic UNIX philosophy is to use the smallest or simplest tool that does the job. In this case that's clearly sed. (Not to mention the fact that perl isn't even in FreeBSD's base system, so might not be available at all.) Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor, and when was the last time you needed one?" -- Tom Cargil, C++ Journal
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910091701.n99H19sq028830>