#!/usr/bin/perl -- use strict; use warnings; use Data::Dump; my $str ='dog dog dog dog dog'; my @dogs ; while( @dogs < 3 and $str =~ /(dog)/g ){ push @dogs, $1; } dd \@dogs; __END__ ["dog", "dog", "dog"]
In reply to Re: Limiting number of regex matches
by Anonymous Monk
in thread Limiting number of regex matches
by eversuhoshin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |