Ack Regular expression
ack uses Perl regular expressions, and those allow lookahead assertions:
^(?!.*bar).*foo.*$
will match a line that contains foo but doesn't contain bar.
I'm not familiar with the usage of ack, but something like this should work:
ack '^(?!.*bar).*foo.*$' myfile