Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: Adding a co...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 1386 of 1496
Post > Topic >>

Re: Adding a comma to format localtime

by tigger@[EMAIL PROTECTED] (Paul Archer) Apr 12, 2007 at 05:56 AM

A cleaner way to do it is:
printf "%s, %s %s %s %s\n", (split ' ', localtime)[0,2,1,4,3];
Or, if you want to save it to a variable:
my $dateout = sprintf "%s, %s %s %s %s\n", (split ' ',
localtime)[0,2,1,4,3];

Paul


11:57am, Susheel Kou****k wrote:

> use this:
>
> $str = localtime;
> @[EMAIL PROTECTED]
 = split/ /,$str;
> $str2 = "$fields[0]".","." $fields[2]"." $fields[1]"." $fields[4]"."
> $fields[3]";
> print ("$str2\n");
>
> On 4/9/07, Gregg O'Donnell <gpod363@[EMAIL PROTECTED]
> wrote:
>> All,
>>   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
>> 
>>   Best and thanks,
>>   Gregg
>> 
>>  	---------------------------------
>> Looking for earth-friendly autos?
>>  Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
>
> -- 
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@[EMAIL PROTECTED]
> For additional commands, e-mail: beginners-cgi-help@[EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>



-------------------------------------------------------------------
Perl elegant? Perl is like your grandfather's garage. Sure, he kept
most of it tidy to please your grandmother but there was always one
corner where you could find the most amazing junk. And some days,
when you were particularly lucky, he'd show you how it worked.
----------Shawn Corey <shawn.corey [at] sympatico.ca>--------------
 




 6 Posts in Topic:
Adding a comma to format localtime
gpod363@[EMAIL PROTECTED]  2007-04-09 09:41:57 
Re: Adding a comma to format localtime
wiggins@[EMAIL PROTECTED]  2007-04-09 11:11:52 
Re: Adding a comma to format localtime
krahnj@[EMAIL PROTECTED]   2007-04-11 09:35:52 
Re: Adding a comma to format localtime
susheelm@[EMAIL PROTECTED  2007-04-12 11:57:39 
Re: Adding a comma to format localtime
tigger@[EMAIL PROTECTED]   2007-04-12 05:56:14 
Re: Adding a comma to format localtime
Peter@[EMAIL PROTECTED]   2007-04-12 06:54:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:57:04 CST 2008.