From owner-freebsd-questions@FreeBSD.ORG Fri Apr 16 20:24:10 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 212EF16A4CE for ; Fri, 16 Apr 2004 20:24:10 -0700 (PDT) Received: from wonkity.com (wonkity.com [65.173.111.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id A441F43D3F for ; Fri, 16 Apr 2004 20:24:09 -0700 (PDT) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.12.11/8.12.11) with ESMTP id i3H3O8Kr002374; Fri, 16 Apr 2004 21:24:08 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.12.11/8.12.11/Submit) with ESMTP id i3H3O84M002371; Fri, 16 Apr 2004 21:24:08 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Fri, 16 Apr 2004 21:24:07 -0600 (MDT) From: Warren Block To: Shaun Friedle In-Reply-To: <1082149145.280.9.camel@Shaun> Message-ID: <20040416210829.A1689@wonkity.com> References: <1082149145.280.9.camel@Shaun> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE cc: freebsd-questions@freebsd.org Subject: Re: perl script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2004 03:24:10 -0000 On Fri, 16 Apr 2004, Shaun Friedle wrote: > #!/usr/bin/perl > $timezone=3D`date +\%z`;=09=09#Gets the offset in $timezone > $timezone =3D~ s/(\+[0-9][0-9])/$1:/;=09#Replaces =B1NN with =B1NN: > print $timezone;=09=09=09#Prints $timezone The regex should allow either a plus or a minus as the first character: s/([+-][0-9]{2})/$1:/ I like Perl a lot, and use it often, but it seems a bit much for this. If there were easy shell substring operations... Anyway, shell-only: date +%z | sed 's/.../&:/'=09# insert colon after first three chars -Warren Block * Rapid City, South Dakota USA