while () { $count += () = m/foo/g } print $count; #### while () { while (/foo/g) { $count++; print "$count so far.\n"; } } #### my $count; while () { if ( $count += s/foo/foo/g ) { print "$count so far\n" ) }