$cmd = qq|grep '$string' access.log|; open(LOG,"$cmd|"); while () { # etc..