in reply to Learn Unix multiline syntax
Remember that the “multi-line syntax” of the shell is simply a cue to the shell that it should not execute the current input immediately, but should instead prompt for another line of input. The shell removes the trailing backslash from each line before processing the concatenated remainder.
In Perl, you will simply create a string variable containing the entire command that you wish to execute. This string should not contain “continuation characters.” If the string needs to contain any special characters, remember that they might need to be properly “escaped.”
Finally, remember how Perl treats string literals that are enclosed with double quotes differently from those that are enclosed with single quotes. Double-quoted strings are interpolated, which means that Perl looks for things that appear to be variable-references in such strings, and attempts to replace them with the value of the corresponding variable.
A good, practical approach is to first simply print the string to STDERR, to see if it is correct. Stop coding at that point, and make corrections as necessary. When all is well, proceed to finish the program.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Learn Unix multiline syntax
by locked_user sundialsvc4 (Abbot) on Aug 16, 2010 at 22:22 UTC |