#!/usr/bin/perl -w #this file is for grepping within vdx files, and outputs the following: #filename:<#of hits>: #filename:2:myargument open ARGUMENTS, "<","file"; @files = <*.vdx>; @arguments = ; foreach $file (@files) { #$copyfile="\"".$file."\""; foreach $argument (@arguments) { chomp $argument; #print "$copyfile\n"; # 0. move these _down_ to here ($ENV{f},$ENV{a})=($file,$argument); # 1. consider egrep instead for a bit more readable posix regexes # 2. two ways to make grep include file names: the newish -H or # the classic /dev/null trick (the last second change was also a last # check misread your opening to imply missing _file_ argument :/) $results=`grep -H -c "\$a" "\$f"`; # /dev/null`; # 3. do you really want to see non-match reports? $rc=$?; next if $rc; # nothing to report # 4. but gnu grep ... /dev/null now insists to sumarize non hits as well # $results=~s/\n.*//sgo; chomp $results; print "$results:$argument\n"; } }