#!/usr/bin/perl -w use strict; use warnings; use File::Find; use File::Find; my $folder= "oem"; my @array="./oem.h"; my @content; @content = grep {/\Q$folder\E/} @array; print "@content";#prints ./oem.h instead of the matched content