perl -wpe 'if (($_f ||= /\bremotely\b/) &&= !/\bp_args\b/) { chomp }' a