Re: string matching specific number of times




Dave Weaver wrote:
> ced@xxxxxxxxxxxxxxxxxxxxx <ced@xxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > Or, simply:
> >
> > my $count = 0;
> > $count++ while $something =~ /test/g;
>
> Or save yourself the loop:
>
> my $count = () = $something =~ /test/g;


There's still a loop returning values which are just discarded
by the empty list of course. Losing the counter init./increm.
is very cool though.

--
Charles DeRykus

.



Relevant Pages

  • Re: Perl script does nt parses d entire excel file please help
    ... Dave Weaver wrote: ... one loop from 1, ... Looks a little odd to me. ... This sort of thing is better written: ...
    (comp.lang.perl.misc)
  • Re: processing a sequence
    ... (loop for sublist = (collect-sublist) ... return accum if not element = list.first ... if prev and element < prev ... James still didn?t show his Ruby one-liner that outperforms the Lisp ...
    (comp.lang.lisp)
  • Re: Process notification
    ... As you see from prev. ... posts there is no obsolute user mode solution on how ... and then immidiatly terminated - your "monitoring loop" may not detect it. ... Vladimir ...
    (microsoft.public.win32.programmer.kernel)
  • RE: Extreme beginner question on reading lines from a file.
    ... print FILEOUT "M98PPECK.SUBL1\n"; ... the 1st line is written into $prev. ... This code will fail if there's ... If it fails it returns false and the loop exits. ...
    (perl.beginners)
  • copy error
    ... each time through loop ... It also returns a '1' which I dont not understand since it ... Shouldnt it be '0'? ... Prev by Date: ...
    (comp.lang.perl.misc)