You shell out multiple times. The performance of the Perl code seems inconsequential.
This post will cover some cleanups (but leaves the important question of parallelism unanswered).
I don't think
map { $1 if /^\w+:\s+(\w+)\b/ }
has a defined behaviour. You want
map { /^\w+:\s+(\w+)\b/ }
And the grep { /^\w+:/ } is completely redundant.
Backticks returns the captured output as lines in list context, so
split /\n/, `gst-inspect-1.0`
can be replaced with
`gst-inspect-1.0`
It's not equivalent since it leaves the line feeds in, but that's not an issue for you.
Cleaned:
my %plugins =
map { $_ => scalar `gst-inspect-1.0 $_` }
map { /^\w+:\s+(\w+)\b/ }
`gst-inspect-1.0`;
You could even combine the two maps, but I wouldn't.
my %plugins =
map { /^\w+:\s+(\w+)\b/ ? $1 => scalar `gst-inspect-1.0 $1` : () }
`gst-inspect-1.0`;
Seeking work! You can reach me at ikegami@adaelis.com
|