Can someone tell me what does this line do ?
$line =~ m/^\|\s*\w\S*\s*(?:\|.+?){10,}\|$/o
I know that it check to see if the line begin with "|" follow by
whitespace, word, nonwhitespace and than I'm lost. What is s*(?:\|.+?)
Make that "|" followed by optional whitespace, a word character, optional
nonwhitespace, optional whitespace, ten or more of "these": |x..., and
ending in "|".
Also, it's not s*(?:\|.+?), it's \s*(?:\|..+?). (?:...) are grouping (not
capturing) parentheses. They're followed by {10,} so you want 10 or more
of those groups. Each group is "|" followed by at least one, possibly
more, character(s) that match(es) /./ but not "|" (because +? is
non-greedy).
Below is an expanded (using /x) version:
# example line that will match
my $line = '| abc |0|1|2|3|4|5|6|7|8|9|x|y|z|';
$line =~ m/^\|\s*\w\S*\s*(?:\|.+?){10,}\|$/o and print "yes\n";
$line =~ m/
^ # begins with
\| # 'or' bar
\s* # optional whitespace
\w # ONE word character
\S* # optional nonwhitespace
\s* # optional whitespace
(?: # begin the group
\| # 'or' bar
.+ # at least one character
? # make the '+' non-greedy
) # end the group
{10,} # give me 10 or more GROUPS
\| # 'or' bar
$ # at the end
/ox and print "yes\n";
I assume you've looked at perldoc perlre.
Regards,
Brad