The question you have asked only concerns how the shell interprets its input and passes it along to other programs. It has nothing to do with Perl, per se.
You should just be able to put this in a script:
The argument given to the command will have a newline in the same place as it does in the script itself. You may need to take care to save such a script in such a way that it ends with Unix-style (LF-only) line breaks, otherwise you might get a CR+LF (DOS/Windows line breaks) or just CR (old Mac-style lineb reaks). You can also do this at an interactive prompt, but you will see a continuation prompt before the second and any subsequent lines:
$ foo '$x;
In bash, you can also use the
$'' quoting syntax to encode a newline character like this:
The argument passed to the program will be treated in a manner similar to an ANSI C string. If you want an actual backslash in the string you will have to escape it as
So, if you really want the literal-string quoting that single quotes give you, you should probably stick with an embedded newline so that you do not have to worry about extra escaping.