in reply to Re: seeking oneliner improvement
in thread seeking oneliner improvement

Probably better as:

perl -sne " BEGIN { @ARGV = map glob( $_ ), @ARGV } /\[$TAG\]/ ... /\[ +\/$TAG\]/ && print qq[$ARGV($.):$_]; close ARGV if eof " -- -TAG=ta +th_tag ./*/dir/*.ext

  1. glob works on strings, not arrays.
  2. If /\[$TAG\]/ and /\[\/$TAG\]/ are on the same line then .. will not work correctly.
  3. To get the correct line number for each file you need to close the filehandle at eof.
  4. And, without the -- switch the perl interpreter will try to parse -TAG as a valid perl option.