#!/usr/local/bin/perl use strict; use warnings; use re qw(debug); open IN, '<', '/root/Desktop/new file'; while() { if($_ =~ /\$display(.*?);$/i) { print $_; } } close IN;