Xref: utzoo comp.unix.questions:23640 comp.lang.perl:1772 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions,comp.lang.perl Subject: Re: Selective translation Summary: The solution in Perl Message-ID: <1990Jul10.215308.15976@iwarp.intel.com> Date: 10 Jul 90 21:53:08 GMT References: <1553@dfsun1.electro.swri.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Followup-To: comp.unix.questions Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 27 In-Reply-To: jackson@dfsun1.electro.swri.edu (Keith Jackson) In article <1553@dfsun1.electro.swri.edu>, jackson@dfsun1 (Keith Jackson) writes: | I was trying to filter a file by making the first word lowercase and | leaving the rest as is. My solution: | | % awk -f filt1.awk foo | tr A-Z a-z > stage1.b | % pr -m -t -s -l1 stage1.a stage1.b > final | | where filt1.awk contains: | { | print $1; | for (i = 2; i < NF; i++) | printf("%s ", $i) >> "stage1.a"; | if (NF > 1) | print $NF >> "stage1.a"; | } I hope you mean "the first word on each line". That's about the best I could come up with by reverse-engineering your code. In Perl, it'd be: perl -pe 's/^(\W*\w+)/(($x = $1) =~ tr|A-Z|a-z|),$x/e' foo Just another Perl hacker, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/