sanPerl has asked for the wisdom of the Perl Monks concerning the following question:
It is giving me erroruse strict; my $abcd = "Hello how r you?"; my $hello="Hello"; $abcd =~ s{\w} { #{ #}{ if ($hello) {"1"} else {"0"} }exgs; print $abcd;
When I removed line 6 & 7 the code looked as belowSubstitution replacement not terminated at test.pl line 5.
It works proper and gives me output 11111 111 1 111? My question is, why the commented braces are playing role in this error ? Have I done something wrong here?use strict; my $abcd = "Hello how r you?"; my $hello="Hello"; $abcd =~ s{\w} { if ($hello) {"1"} else {"0"} }exgs; print $abcd;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Commented braces in Code
by ikegami (Patriarch) on Sep 11, 2007 at 13:21 UTC | |
|
Re: Commented braces in Code
by moritz (Cardinal) on Sep 11, 2007 at 12:59 UTC | |
|
Re: Commented braces in Code
by ww (Archbishop) on Sep 11, 2007 at 13:17 UTC | |
|
Re: Commented braces in Code
by CountZero (Bishop) on Sep 11, 2007 at 20:03 UTC | |
by sanPerl (Friar) on Sep 12, 2007 at 07:59 UTC |