[Pdx-pm] sanity check: how to use system()

Michael G Schwern schwern at pobox.com
Wed Mar 2 08:14:02 PST 2005

On Tue, Mar 01, 2005 at 12:03:34AM -0600, Eric Wilhelm wrote:
> What's the deal with this bit of code:
>   unless(system(join ' ', @command) == 0) ...
> ?!


> Then, I come across the above needless join of a perfectly LISTlike 
> @command and I think I surely must have lost it.  Is there a historical 
> reason or something here that I'm missing?

Do not attribute to malice (or design) what can easily be attributed to

More than likely they're simply not aware that system() can take a list.
Many people don't look at perldoc, they read awful books with misleading
examples.  Or they naturally figure that system() only takes a string and
don't bother to look at a man page.  Additionally, security or special shell
characters are not taken into account and don't come up.

Now it is possible they deliberately want to run the command through the
shell but rather unlikely.  Don't pull your hair out over it.

More information about the Pdx-pm-list mailing list