Re: Adding a comma to format localtime

[email protected] ("John W. Krahn")
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
Gregg O'Donnell wrote:
> 
> I use this line of code:
> my $datetime = join ' ', (split ' ', localtime)[0,2,1,4,3];
> 
> To create this result:
> Mon 9 Apr 2007 09:15:05
> 
> How can I add a comma to this result to get:
> Mon, 9 Apr 2007 09:15:05

( my $datetime = localtime ) =~ s{(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)}
                                 {$1, $3 $2 $5 $4};



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.