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


In reply to Re: More Effecient Method Chaining by ikegami
in thread More Effecient Method Chaining by fennewald

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.