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: 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/.../&:/' # insert colon after first three chars -Warren Block * Rapid City, South Dakota USA _______________________________________________ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"