Eugene has asked for the wisdom of the Perl Monks concerning the following question:
the code works and @a gets all the matches.%hash = ('"', '"', '/*', '*/', '<-', '->'); foreach (keys(%hash)) { $start = $_; $end = $hash{$_}; my $inside = 0; my $oldpos = 0; while ($string =~ /(?<!\\)(\Q$start\E|\Q$end\E)/g) { if ($inside == 0) { $oldpos = pos($string) - length($start); $inside++; } else { push (@a, substr($string, $oldpos, pos($string)-$oldpos)); $inside--; } } }
and then run the same code as above, my $string gets split by character, and each element of @a receives a single character.while($db->FetchRow()) { undef %mult; %mult = $db->DataHash(); push (@multy, values(%mult)); } %hash = reverse(@multy);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: strange hash behavior
by perlmonkey (Hermit) on May 27, 2000 at 10:35 UTC | |
by Eugene (Scribe) on May 27, 2000 at 10:50 UTC | |
by Eugene (Scribe) on May 27, 2000 at 11:17 UTC |