Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created February 25, 2014 00:47
Show Gist options
  • Save schnell18/9200423 to your computer and use it in GitHub Desktop.
Save schnell18/9200423 to your computer and use it in GitHub Desktop.
Code snippet to run external command and get the output in Perl
my $cmd_base = "...";
my @cmd_opts = qw(
...
);
my $cmd_args = "...";
my $cmd = join(" ", $cmd_base, @cmd_opts, $cmd_args);
my $ph;
open($ph, "$cmd |") or do {
warn("Can not run command $cmd due to: $!");
};
while(<$ph>) {
chomp;
}
close($ph);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment