Desiccation
life% more growup
#!/usr/bin/perl
use strict;
while (<>) {
s/play/work/g;
s/want to/have to/g;
s/ free time//g;
s/summers?/retirement/g;
s/imagine?/remember/g;
s/future/past/g;
print;
}
life% growup < dreams > responsibilities
life% rm dreams
|
Desiccation
describes theProcess
of becoming an adult, in the worst sense of the word. The primary script (in grey) is written in Perl, which is a high-level scripting language. The beauty of scripting languages is how little setup is required. (Note how there is no Full Code tab for thisProcess
.) The rest of the "code" shown is taken from a session of using the Unix operating system.life%
is a Unix prompt;life
is probably the server name, but might also be the current user or directory. The Unix commandmore
prints the contents of a file to the screen. Here, we are looking at the contents of thegrowup
file, which is a Perl script.This script continues to read in each line of input, and performs a number of search-and-replace operations on the incoming text, as directed by all the
s///;
lines. Theg
at the end of each of these lines stands forglobal
, which means Perl will replace all instances and not only the first. A?
means the preceding letter is optional. (In practice, "regular expressions" like these tend to be a bit more complex and versatile.) Finally, the script prints out the changed lines. This sort of script is often called a filter.After viewing the contents of this file, we direct the contents of the file
dreams
through thegrowup
filter, and dump the output into a file calledresponsibilities
. We then remove (delete) the originaldreams
file.As an example of how this works, if our original
dreams
file contained this:our
responsibilities
file would contain this: