Created
February 25, 2014 00:47
-
-
Save schnell18/9200423 to your computer and use it in GitHub Desktop.
Code snippet to run external command and get the output in Perl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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