Bourne-like shells have an ability commonly referred to as "here files" or "here documents". A simple example is:
LS=`ls` cat <<STUFF hello $LS bye STUFF
Many programmers and scripters will use EOF as the marker, though what you use is entirely up to you.
Perl uses a similar syntax, the only real difference being the requirement for a terminating semicolon on the invoking line:
#!/usr/bin/perl print <<EOF; hello .. bye EOF
Perl can be a bit trickier about this than the shell can; see the Perl documentation for examples.
Probably the most creative use of "here" syntax is the "shar" program, which bundles files up into a self extracting shell script using here documents.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-07-07 Tony Lawrence
If we define Futurism as an exploration beyond accepted limits, then the nature of limiting systems becomes the first object of exploration. (Frank Herbert)