如何在Perl程序中使用以下命令?
cat file| sed -n '/Later/p' |
sed -n '/A character range is written as two characters separated by{}/!p' |
sed -n '/ range is not specified{}/!p'
如何在Perl程序中使用以下命令?
cat file| sed -n '/Later/p' |
sed -n '/A character range is written as two characters separated by{}/!p' |
sed -n '/ range is not specified{}/!p'
最好根本没有。Perl 为您提供的不仅仅是普通的 sed,如果您可以在 Perl 本身中做同样的事情,您就不会为了使用 sed 而付出额外的开销:
use strict;
use warnings;
open my $filehandle, '<', 'file' or die "could not open file: $!\n";
while (<$filehandle>) {
if ( /pattern one/ and not /pattern two/ and not /pattern three/ ) { print }
}