fennewald has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing some one off functionality to work with other CLI tools. I was curious (1) what was the idiomatic way to do what I describe, and (2) if there is a faster way
This specific example deals with the command gst-inspect-1.0. You don't need to know what it does, just this. Calling gst-inspect-1.0 without arguements returns a list of plugins. Calling gst-inspect-1.0 with a plugin name returns information about that specific plugin. Each call to gst-inspect-1.0 takes about half a second, give or take (so suprisingly long).
I want to work with the description for each plugin, so I wrote the following snippet:
Is my code idiomatic? Should I be creating separate arrays for each of these steps? Is there any way to have line 2 run in parallel? Each call does take a while and it adds up fast with ~1000 plugins!my %plugins = map { $_ => scalar `gst-inspect-1.0 $_` } # Inspect the plugin map { $1 if /^\w+:\s+(\w+)\b/ } # Reduce to plugin name grep { /^\w+:/ } # Filter header and empt +y lines out split /\n/, `gst-inspect-1.0`; # Bring in input
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: More Effecient Method Chaining
by ikegami (Patriarch) on Apr 21, 2021 at 22:20 UTC | |
by perlfan (Parson) on Apr 22, 2021 at 05:11 UTC | |
by Anonymous Monk on Apr 22, 2021 at 07:34 UTC | |
Re: More Effecient Method Chaining
by eyepopslikeamosquito (Archbishop) on Apr 22, 2021 at 09:21 UTC | |
Re: More Effecient Method Chaining
by jcb (Parson) on Apr 23, 2021 at 23:14 UTC |