On 30 Jun 2014, at 20:05, Jim Gibson <jimsgib...@gmail.com> wrote: > Try this: > > $c = () = $line =~ /\b$w\b/g;
Or, slightly less obscure: #!/usr/bin/perl use strict; my $line = "one potato two potato three potato four"; my @hits = $line =~ /potato/g; print scalar @hits; # => 3 #JD -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/