Q:

How can I print a message for each substitution in my Perl one-liner? 

I use the following Perl syntax in my bash script:
     perl -i –pe  'next if /^ *#/; s/(\b|\D)$ENV{OLD }(\b|\D)/$1$ENV{NEW }$2/'   file

I want to find the OLD word without first "#" character in the file ,  then replaces the OLD word with NEW word
My question: I want to print "replace $OLD with $NEW" each time perl replace the $OLD with $NEW
In which way?  we can insert the command:  print "replaced $OLD with $NEW ";  in the Perl syntax? 
Please notice that perl one-liner syntax is part of my bash script

A:

perl -i –pe  'next if /^ *#/; s/(\b|\D)$ENV{OLD }(\b|\D)/$1$ENV{NEW }$2/ && warn "replaced $OLD with $NEW\n"' file

