Date: Fri, 22 Aug 2008 09:59:56 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-questions@FreeBSD.ORG, walt@wump.org, steve@ibctech.ca Subject: Re: sed/awk, instead of Perl Message-ID: <200808220759.m7M7xuh0047625@lurza.secnetix.de> In-Reply-To: <p06240804c4d3a88262e4@[10.0.0.10]>
next in thread | previous in thread | raw e-mail | index | archive | help
Walt Pawley wrote: > Walt Pawley wrote: > > Walt Pawley wrote: > > > Steve Bertrand wrote: > > > > - read email addresses from a file in the format: > > > > > > > > user.name TAB domain.tld > > > > > > > > - convert it to: > > > > > > > > user_name@example.com > > > > > > > > - write it back to either a new file, the original file, or to STDOUT > > > > > > I'm curious why Perl isn't a decent choice. I think I'd do something like > > > > > > perl -pe 's/(.*?)\.(.*)\t.*/$1_$2@example.com/' input_file > output_file > > > > Which is also wrong. It gets a bit closer to Steve's desires I > > suspect if one adds the appropriate backslash ... > > > > perl -pe 's/(.*?)\.(.*)\t.*/$1_$2@\example.com/' input_file > output_file > > > > Sorry... > > I guess getting old, nearly blind and mind numbing close to > brain dead is better than the alternative. Try this (sooner or > later I've got to get it right)... > > perl -pe 's/(.*?)\.(.*)\t.*/$1_$2\@example.com/' input_file > output_file > > Sorrier. I think your attempts show very well why Steve wanted to avoid perl. :-) But seriously, a few other reasons might include: - tr, sed, awk etc. are part of the FreeBSD base system, while perl is not. - The perl command you wrote above is pretty much a sed command anyway (except you incorrectly used non-portable regular expression syntax). Why use perl to execute a sed command? - It is generally advisable to use the smallest, most light-weight tool that gets thew job done. In this case that's clearly not perl: Size of sed: 27 KB. Size of perl + libperl: 1126 KB Thats more than 40 times bigger. Of course, YMMV. 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 "It combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript." -- Jamie Zawinski, when asked: "What's wrong with perl?"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808220759.m7M7xuh0047625>