#!/usr/local/bin/perl -wT use strict; my $string="test"; # actually comes from CGI $string=~s/[^\w]//; # remove non word chars #clean up environment delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; $ENV{'PATH'} = '/bin:/usr/bin'; if (open (GREP, "-|")) { print ; } else { exec ("grep", "-r", $string, ".") || die "Error exec'ing command", "\n"; } close (GREP);