On Fri, 16 Apr 2004, Shaun Friedle wrote:

> #!/usr/bin/perl
> $timezone=`date +\%z`;                #Gets the offset in $timezone
> $timezone =~ s/(\+[0-9][0-9])/$1:/;   #Replaces ±NN with ±NN:
> print $timezone;                      #Prints $timezone

The regex should allow either a plus or a minus as the first character:

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/.../&:/'      # insert colon after first three chars

-Warren Block * Rapid City, South Dakota USA
[EMAIL PROTECTED] mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to