Perl logo

Perl Refreshments ⌘

Treat - Calling Other Programs from Perl 2

Finally we get to see how to put these examples into your Perl script. As mentioned, we use the Perl command 'system'.

my @SysCmd=("exiftool somefile.flac", " | ", "egrep 'Album|Artist|Genre|Title|Track|Duration'", " > ", "somefile.txt");
system(@SysCmd);

As a Perl programmer you will recognize starting out by assigning an array called '@SysCmd'. It holds the various strings which will be executed when we actually run it. In this case it holds 5 elements, quoted and separated by commas.

This is done to avoid using the shell - if you need to do that, just wrap the whole string in quotes and eliminate the commas.

The last line actually uses the Perl 'system' command to execute whatever was in @SysCmd.

Here Documents

-30-