This is a classic case of fork() confusion- it is called once but "returns twice". Really, it returns once in your parent and once in the child. When you fork, you create a new process.
execing over this program space creates a program that runs in the space where the previous fork was. This is what
system does, fork and exec (with some signal stuff and security stuff which is why you shouldn't try to substitute for it). Once you fork, you can change the pipe information to pipe anywhere you want. The exec does not modify this so if you pipe STDIN of the kid to the STDOUT of the parent, you have a model system where you can pipe info to the kid even though it was designed to run from the shell. Nifty, eh? What happens here is that the unless makes sure that you are in the kid (fork returns 0), and execs over the space where the PIPE was opened to return back to the parent. The pipe is maintained over the exec and thus, information is able to be returned. In order, not be confused, keep in mind, that you can have an arbitrary number of processes in any ONE Perl script.
I see this as more secure because you are guaranteed not to be able to open any other processes. Now that you have figlet running, nothing that you send to figlet will cause it to open any other program (I know my figlet! :-D). In the first case, you are running through the shell. In the second case, the shell is not involved. If you pass bad values to figlet, it will not be interpolated by the shell. If there are illegal instructions passed, figlet will simply die. That's it!
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.