From owner-freebsd-questions@FreeBSD.ORG Fri Aug 22 08:00:02 2008 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E724B106567B for ; Fri, 22 Aug 2008 08:00:02 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 4F3FB8FC26 for ; Fri, 22 Aug 2008 08:00:02 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.2/8.14.2) with ESMTP id m7M7xvbX047626; Fri, 22 Aug 2008 10:00:00 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.2/8.14.2/Submit) id m7M7xuh0047625; Fri, 22 Aug 2008 09:59:56 +0200 (CEST) (envelope-from olli) Date: Fri, 22 Aug 2008 09:59:56 +0200 (CEST) Message-Id: <200808220759.m7M7xuh0047625@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG, walt@wump.org, steve@ibctech.ca In-Reply-To: X-Newsgroups: list.freebsd-questions User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.3-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Fri, 22 Aug 2008 10:00:00 +0200 (CEST) Cc: Subject: Re: sed/awk, instead of Perl X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.ORG, walt@wump.org, steve@ibctech.ca List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 08:00:03 -0000 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?"