perlfaq nodetype
faq_monk
<P>
The problem is usually that the command interpreters on those systems have
rather different ideas about quoting than the Unix shells under which the
one-liners were created. On some systems, you may have to change
single-quotes to double ones, which you must <EM>NOT</EM> do on Unix or Plan9 systems. You might also have to change a single % to a
%%.
<P>
For example:
<P>
<PRE> # Unix
perl -e 'print "Hello world\n"'
</PRE>
<P>
<PRE> # DOS, etc.
perl -e "print \"Hello world\n\""
</PRE>
<P>
<PRE> # Mac
print "Hello world\n"
(then Run "Myscript" or Shift-Command-R)
</PRE>
<P>
<PRE> # VMS
perl -e "print ""Hello world\n"""
</PRE>
<P>
The problem is that none of this is reliable: it depends on the command interpreter. Under Unix, the first two often work. Under
<FONT SIZE=-1>DOS,</FONT> it's entirely possible neither works. If
<FONT SIZE=-1>4DOS</FONT> was the command shell, you'd probably have better luck like this:
<P>
<PRE> perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
</PRE>
<P>
Under the Mac, it depends which environment you are using. The MacPerl shell, or
<FONT SIZE=-1>MPW,</FONT> is much like Unix shells in its support for several quoting variants, except that it makes free use of the Mac's non-ASCII characters as control characters.
<P>
There is no general solution to all of this. It is a mess, pure and simple.
Sucks to be away from Unix, huh? :-)
<P>
[Some of this answer was contributed by Kenneth Albanowski.]
<P>