Date: Fri, 16 Apr 2004 21:24:07 -0600 (MDT) From: Warren Block <wblock@wonkity.com> To: Shaun Friedle <shaun@insipidity.co.uk> Cc: freebsd-questions@freebsd.org Subject: Re: perl script help Message-ID: <20040416210829.A1689@wonkity.com> In-Reply-To: <1082149145.280.9.camel@Shaun> References: <MIEPLLIBMLEEABPDBIEGAEBCFMAA.Barbish3@adelphia.net> <1082149145.280.9.camel@Shaun>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040416210829.A1689>