John W. Krahn wrote:
Mariano Loza Coll wrote:
Hi John,

Hello,

I'm trying to learn a little bit more of Perl everyday, and I was
intrigued about your earlier suggestion in a thread.


my $bad_chromosomes = qr/^(?:6|8|14|16|18|Y)\t/;

while (<$IN>  ) {
    print $OUT $_ if !/$bad_chromosomes/;
    }


I get the spirit of what you suggested, but I was curious about the use of "?:"

() are capturing parentheses and

(?:) are non-capturing parentheses.


If I got it right, the "?" will make the search non-greedy. But what
is the ":" for?

The (?:... ) notation is non-capturing. The ?: makes it non capturing.
In this context, the '?' is not used to control greediness.

In perlre, look for the section 'Extended Patterns', then down a page look for:

(?:pattern)
(?adluimsx-imsx:pattern)
(?^aluimsx:pattern)

Chris


perldoc perlre



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to