Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am no great expert in perl, so there is quite possibly a quicker way to this, but it seems like the match operator "<code>//</code>" in list context is what you need. When you assign the result of a match operation to a list, the match operator takes on list context and returns a list with each of the parenthesis delimited sub-expressions. If you specify global matches with the "<code>g</code>" flag, it will return a list of all the matches of each sub-expression. Example:</p> <pre><code># print a list of each match for "x" in "xxx" @aList = ("xxx" =~ /(x)/g); print(join(".", @aList)); </code></pre> <p>Will print out</p> <pre><code>x.x.x </code></pre> <p>I'm assuming you have a regular expression for each of those 5 types <code>h</code>, <code>D</code>, <code>s</code>, <code>E</code>, and <code>x</code>. You didn't say whether each of these parts is a single character or multiple, so I'm going to assume they can be multiple characters. If so, your solution might be something like this:</p> <pre><code>$h = ""; # Insert regex to match "h" $D = ""; # Insert regex to match "D" $s = ""; # Insert regex to match "s" $E = ""; # Insert regex to match "E" $x = ""; # Insert regex to match "x" $sequenceRE = "($h){3}($D){3}($s){2}($E){2}($x)($D)" if ($line =~ /$sequenceRE/) { $hPart = $1; $sPart = $3; $xPart = $5; @hValues = ($hPart =~ /($h)/g); @sValues = ($sPart =~ /($s)/g); @xValues = ($xPart =~ /($x)/g); } </code></pre> <p>I'm sure there is something I've missed, and there are some subtleties of perl that I have overlooked, but this should get you most of the way there. For more information, read up on perl's <a href="http://www.perl.com/doc/manual/html/pod/perlop.html#Regexp_Quote_Like_Operators" rel="nofollow noreferrer">match operator</a>, and <a href="http://www.perl.com/doc/manual/html/pod/perlre.html" rel="nofollow noreferrer">regular expressions</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload