my $cmd = "tac temp.xx | sed -n '/$mod /,/YYY/ p'| grep XXX"; print "executing: '$cmd'\n"; $hier = `$cmd`; print "result: '$hier'\n";