如何在perl one衬纸中查看由n或p开关生成的代码块 [英] How to view the code block genereated by n or p switch in perl one liner

查看:67
本文介绍了如何在perl one衬纸中查看由n或p开关生成的代码块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信我以前曾经运行过此程序,但是我一生无法在perlrun或Google中找到任何参考. 希望这里的一些perl boffins能够回答它. 使用-ne开关运行perl时,需要一个内衬.有没有可以将perl编译的代码输出到控制台的选项?

I am sure I have run this before but for the life of me cant find any reference in perlrun or through Google. Hopefully some of the perl boffins here will be able to answer it. When running a perl one liner with the -ne switch. Is there an option to have the code, that perl will compile, to be outputted to the console?

所以,如果我跑步:

crontab -l | perl -ne 'print if /^00/'

然后Perl会将其编译为:

Then Perl will compile this to:

while(<>){
   print if /^00/;
}

我确信有一种方法可以让perl吐出将要使用的代码,包括任何开始或结束块.希望有人知道.

I am sure there is a way to have perl spit out the code its going to use including any begin or end blocks. hopefully someone knows how.

推荐答案

您可能会想到 B::Deparse 函数:

You may be thinking of the B::Deparse function:

perl -MO=Deparse -ne 'print if /^00/'

这篇关于如何在perl one衬纸中查看由n或p开关生成的代码块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆