From owner-freebsd-questions Wed Jan 23 12:11: 5 2002 Delivered-To: freebsd-questions@freebsd.org Received: from primus.vsservices.com (primus.vsservices.com [63.66.136.75]) by hub.freebsd.org (Postfix) with ESMTP id 1AC2037B402 for ; Wed, 23 Jan 2002 12:10:58 -0800 (PST) Received: from prime.vsservices.com (conr-adsl-dhcp-26-38.txucom.net [209.34.26.38]) by primus.vsservices.com (8.11.3/8.11.3) with SMTP id g0NKAqH92202; Wed, 23 Jan 2002 12:10:52 -0800 (PST) (envelope-from gclarkii@vsservices.com) Date: Wed, 23 Jan 2002 14:10:52 -0600 From: GB Clark To: Eric Six Cc: questions@FreeBSD.ORG Subject: Re: Text editiing.... possibility for perl? Message-Id: <20020123141052.1ed22c74.gclarkii@vsservices.com> In-Reply-To: References: X-Mailer: Sylpheed version 0.6.6 (GTK+ 1.2.10; i386-unknown-freebsd4.4) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 23 Jan 2002 13:34:27 -0600 Eric Six wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I have a few questions.. I need to edit a few files with a bunch > text. I am creating forward and reverse zone file for a private > network and I want to automate this tedious process.. Here is what I > have. > > I create a basic template in excel, it is as follows; > > host15,1,in,a,10,50,15,1 > host15,2,in,a,10,50,15,2 > host15,3,in,a,10,50,15,3 > > > What I need done after this file is populated is make it look like > this; > host15-1 in a 10.50.15.1 > host15-2 in a 10.50.15.2 > host15-3 in a 10.50.15.3 > > So I need the first comma changed to a minus, the next two comma's a > tab, and the last three changed to periods. I can do some of this > with 'cut' but not everything I want to do... I figure I cannot be > the only one that has had to populate a massive amount of forward and > reverse files in bind.. I figure there might be a perl script for > this?? > > > TIA > Eric > Eric, This is a very quick hack but it should work. I tested is with your data and it output what you wanted. Hope it helps. GB --CUT-- #!/usr/bin/perl -w use strict; while (<>) { chomp; my($def1, $def2, $def3, $def4, $def5, $def6, $def7, $def8) = split(',', $_); print "$def1-$def2\t$def3\t$def4\t$def5.$def6.$def7.$def8\n"; } -- GB Clark II | Roaming FreeBSD Admin gclarkii@VSServices.COM | General Geek CTHULU for President - Why choose the lesser of two evils? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message