![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl script to search sprintf and replace with snprintf | ChaMeN | Shell Programming and Scripting | 1 | 03-22-2009 02:36 PM |
| sprintf result on perl | Zaxon | Shell Programming and Scripting | 2 | 03-10-2009 05:03 AM |
| equivalent of sprintf in C++ | dhanamurthy | High Level Programming | 1 | 05-20-2008 10:18 PM |
| perl: printf indentation problem | wolwy_pete | Shell Programming and Scripting | 5 | 03-27-2008 08:09 PM |
| sprintf function | whatisthis | High Level Programming | 1 | 05-01-2006 05:58 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
printf vs sprintf - perl
I would like to assign the output of printf to a variable in perl , it give me back a "1" instead of the time. How can I stuff the variable with what printf returns? Here is my code: Code:
#!/usr/bin/perl
$time = localtime(time);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$newtime = printf ("%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
print "$newtime\n";
Any suggestions? Thanks in advance. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|