What is wrong in this Perl regex in OSX? The code works in Ubuntu, but not in OSX.

I run

perl -000pe 's/\n/\n\\begin{enumerate}\n/; s/\n\d./\n\\item /g; s/$/\\end{enumerate}\n/' lorem.tex


I get 

-bash: $: command not found
MacBook-Air:draft masi$
It seems like you might have cut-n-pasted the command in to the shell in some odd way - or you manually entered it in the wrong way.

Try again, and this time pay attention to the quote characters. You need to use the right apostrophes. Make sure you don't use backticks or similar.