On Tue, Jul 31, 2012 at 12:54 AM, moijes12 <moije...@gmail.com> wrote:
> When I execute this program from the command line by running "./ > grep.pl (.es.){3} /usr/share/dict/words" , I get the error > bash: syntax error near unexpected token `.es.' > > But, if execute it as "./grep.pl \(.es.\){3} /usr/share/dict/ > words" , I get the expected result. > The parenthesis and curly braces mean something special to the command line. It's not a Perl issue. It's a shell issue. In your case, the "bash" shell. "bash" tries to interpret "(.es.){3}" before running Perl. Those extra slashes you added tell "bash" to not interpret the parenthesis. You could also get around the problem by quoting the regular expression on the command line, like this: # ./grep.pl '(.es.){3}' /usr/share/dict/words Hope that helps. -- Robert Wohlfarth