从bash切换到Perl

问题描述:



我最近开始使用bash并写了一些代码,通过使用grep来查找租约文件中的某些IP和相关内容

我试图切换到perl的。我是一个大人物,并试图通过阅读网上的东西来学习perl。

我在下一点陷入困境

我用bash写的

grep $ IP data061009 -A


现在在perl我写的是

@ result = grep(/ $ IP /,$ _)在while循环中。

如何在perl中加入''-A 6''部分

请帮忙。

Hi,
I recently started using bash and wrote some code to find certain IPs and related stuff in the leases files by using grep
I am trying to switch to perl. I am a bigginer and trying to learn perl by reading stuff on net.
I am getting stuck at following point
I wrote in bash
grep $IP data061009 -A 6

Now in perl I am writing
@result= grep (/$IP/, $_) in a while loop.
How do I incorporate ''-A 6'' part in perl
Please help.

IP data061009 -A 6

现在在perl我写的是

@ result = grep(/
IP data061009 -A 6

Now in perl I am writing
@result= grep (/


IP /,


_)在while循环中。

如何在perl中加入''-A 6''部分

请帮忙。
_) in a while loop.
How do I incorporate ''-A 6'' part in perl
Please help.