---
title: "perl在一个文件里搜索一个pattern"
author: "polyahu"
date: "2013-02-26T21:01:03Z"
tags: []
categories: ["编程语言"]
slug: "perl-pattern"
draft: false
lastmod: "2013-02-26T21:01:03Z"
id: 1815549
url: "https://polyahu.iteye.com/blog/1815549"
---

perl在一个文件里搜索一个pattern


```perl

#!/usr/bin/perl
open FH,'< ./input.file';
@lines = <FH>;
foreach $line (@lines)
{
  print $line if $line =~ m/pattern/;
}

```