Hi Everyone
i have a perl file below, one of the line is convert the pcho time to human readable format.
$value=`awk 'BEGIN{print strftime("%c",1273236600)}' | tr -d '\n'`;
if image, if i have lots of pcho time value in a file, if i use this awk, strftime, then tr -d to remove the \n, then assign it to the variable, this process is very slow.
any way to improve it? like perl has built in function, instead of `` the awk.
Thanks
jimmy_y:
Hi Everyone
i have a perl file below, one of the line is convert the pcho time to human readable format.
$value=`awk 'BEGIN{print strftime("%c",1273236600)}' | tr -d '\n'`;
if image, if i have lots of pcho time value in a file, if i use this awk, strftime, then tr -d to remove the \n, then assign it to the variable, this process is very slow.
any way to improve it? like perl has built in function, instead of `` the awk.
...
If you are looking for the equivalent of this -
awk 'BEGIN{print strftime("%c",1273236600)}'
in Perl, then you may want to use the "POSIX" module, which includes the strftime function -
perl -MPOSIX -le 'print POSIX::strftime("%c", localtime 1273236600)'
The POSIX module is part of Perl's standard distribution, atleast on *nix systems. Otherwise CPAN is your one-stop shop.
tyler_durden
1 Like