in reply to Re: why lexical variables can not be interpolated?
in thread why lexical variables can not be interpolated?
Thank you for replying to my questions.
After playing around with this '/e' modifier with s///, I do have a question which I cannot solve now:
$AGE = 17; $text = 'I am $AGE years old'; # note single quotes $text =~ s/(\$\w+)/$1/eeg; # print I am 17 years old $text =~ s/(\$\w+)/$1 * 2/eegx; #I tried to double the age, but faile +d
How I can double the age in s/// format for the above code as showed by a similar but different example:
$text = "I am 17 years old"; $text =~ s/(\d+)/2 * $1/eg; #now I am 34 years old
Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: why lexical variables can not be interpolated?
by kennethk (Abbot) on Oct 21, 2013 at 17:16 UTC | |
by lightoverhead (Pilgrim) on Oct 21, 2013 at 17:42 UTC | |
by SuicideJunkie (Vicar) on Oct 21, 2013 at 18:25 UTC | |
by lightoverhead (Pilgrim) on Oct 21, 2013 at 18:54 UTC | |
by kennethk (Abbot) on Oct 21, 2013 at 18:16 UTC | |
by lightoverhead (Pilgrim) on Oct 21, 2013 at 18:53 UTC |