我想跟踪我的Perl脚本,但只包含代码main,并将输出重定向到文件.
使用perl -d script.pl它启动脚本时会进入交互模式.
我试过了
perl -d:Trace perl_05.pl 2&> output.log
Run Code Online (Sandbox Code Playgroud)
但是这也跟踪了我不想要的所有子程序和模块.
我正在寻找类似bash set -o xtrace或者的东西sh -x.
我的任务是计算当月的最后一天.
有一种方法last_day_of_month在日期时间.你可以这样称呼它:
$av_tmp_TODAY = DateTime->last_day_of_month({year=>2016,month=>05});
Run Code Online (Sandbox Code Playgroud)
但我不想设定固定的年份和月份,我只想采取今天的日期并获得该月的最后一天.
另外,我希望我的输出格式%Y-%m-%d.
I would like to use a Perl variable from my script in a Log::Log4perl config file. I read the documentation and found that I can use a subroutine, but I would like to do it a little bit simpler, if possible.
I want to set the filename for my appender:
log4perl.appender.av_std_LOGFILE.filename="whateverfilename.log"
Run Code Online (Sandbox Code Playgroud)
But doing this this way, it is a fixed value.
I have the filename in a variable within my script and would like to use this at runtime:
log4perl.appender.av_std_LOGFILE.filename=\ …Run Code Online (Sandbox Code Playgroud)