in reply to can't use string refs while "strict refs"

Please wrap code in <code>...</code> tags. See How do I post a question effectively?. Also, the code you quote comes from perlretut. It would have been helpful if you had mentioned this.

i find an error message
#! perl use strict; use warnings; my $x = "Mmm...donut, thought Homer"; $x =~ /^(Mmm|Yech)\.\.\.(donut|peas)/; # matches foreach my $expr (1 .. $#-) { printf "Match %s: '%s' at position (%d, %d)\n", $expr, substr( $x, $-[$expr], $+[$expr] - $-[$expr] ), # fixes t +he error $-[$expr], $+[$expr]; }
please also say how can we find the number of matches for any regexp.
print "Number of matches: $#-\n";

HTH,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^2: can't use string refs while "strict refs"
by artifact (Novice) on Jul 30, 2012 at 07:33 UTC

    Thanks for the help,I now think am capable of understanding Hard references and symbolic reference.. also I'll be aware of the format to post