#!/usr/bin/perl
open(FILE, "檔案名稱" ) or die "Can't open file\n";
@lines = <FILE>;
@hit_line = map { $lnum++; /關鍵字/?$lnum-1:() } @lines;
foreach $hit_line ( @hit_line )
{
print "\n\nHit line number is : $hit_line+1\n\n";
for( ( $hit_line - 5 ) .. ($hit_line + 5 ) )
{
print "$lines[$_]";
}
}
open(FILE, "檔案名稱" ) or die "Can't open file\n";
@lines = <FILE>;
@hit_line = map { $lnum++; /關鍵字/?$lnum-1:() } @lines;
foreach $hit_line ( @hit_line )
{
print "\n\nHit line number is : $hit_line+1\n\n";
for( ( $hit_line - 5 ) .. ($hit_line + 5 ) )
{
print "$lines[$_]";
}
}
沒有留言:
張貼留言