I0 has asked for the wisdom of the Perl Monks concerning the following question:
# I've striped down the core dump example, # It no longer core dumps under v5.6.1 but it still returns the wrong +answer # Can anyone explain why /C(2)/ is not getting substituted? use strict; print doFunc( "MAIN", "B(1)+C(2)" ); sub doFunc{ my $theFunc = shift; local $_ = shift; my $re; $re = ${{ "B(1)+C(2)" => '1|2', }}{$_}||quotemeta; print "$theFunc: '$_'=~/$re/\n"; print join"\n",/(\w+)\(($re)\)/g,"\n"; $_ =~ s/(\w+)\(($re)\)/&doFunc($1,$2)/eg; # /ego works /eg fails return "func $theFunc returns <$_>"; } #should return #func MAIN returns <func B returns <1>+func C returns <2>> #
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: recursive /eg fails
by stephen (Priest) on Mar 27, 2002 at 09:15 UTC | |
|
Re: recursive /eg fails
by derby (Abbot) on Mar 27, 2002 at 13:03 UTC | |
|
Re: recursive /eg fails
by flocto (Pilgrim) on Mar 27, 2002 at 14:39 UTC | |
|
Re: recursive /eg fails
by Anonymous Monk on Mar 27, 2002 at 03:45 UTC | |
by I0 (Priest) on Mar 27, 2002 at 04:01 UTC |