我有一个perl脚本,可以通过a获取当前时间,但我也希望在当前时间之前45天获取日期.这是我有的:
*已经尝试过使用date :: calc DHMS,这就是为什么第二个按照它的方式进行格式化但是它一直返回错误的原因
# get the current time stamp
use POSIX qw( strftime );
my $current_time = strftime("%Y-%m-%d %H:%M:%S", localtime);
print "\n$current_time\n";
# get the date 45 days ago
my $time = strftime("%Y, %m, %d, %H, %M, %S", localtime);
print "\n$time\n\n";
Run Code Online (Sandbox Code Playgroud) 我是新手使用XSL.我试图将输入数据的数据转换为数据捕获模板并生成xml文件.我正在捕获应该是属性值的数据.我知道我的路径是正确的但我在生成过程中遇到错误.救命!
<!-- <xsl:value-of select='odnodes/node/comments'/> -->
<node name="<xsl:value-of select='odnodes/node/name'/>"
host="<xsl:value-of select='odnodes/node/host'/>"
port="<xsl:value-of select='odnodes/node/port'/>"
/>
Run Code Online (Sandbox Code Playgroud)
最终结果看起来像这样:
<!-- uat server - added 2/7/2013 -->
<node name="webserver_uat" host="192.168.1.1" port="20014" />
Run Code Online (Sandbox Code Playgroud) 首先,这是直接来自Learning Perl (p.29)的示例
# Append a space to $str
$str = $str . " ";
# The same thing with an assignment operator
$str .= " ";
Run Code Online (Sandbox Code Playgroud)
出于速度或语法原因,这些方法中的任何一个是否更“正确”或更受欢迎?