Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
For example, the following code has expected behavior where each scalar value in a string is replaced with the appropriate value.
Will naturally print the following string;my $alpha = "A"; my $delta = "D"; my $test = "$delta and $alpha"; print "$test";
Now the following code will behave exactly as I expect it to.
Of course, it will printmy $alpha = "A"; my $delta = "D"; my $test = '$delta and $alpha'; print "$test";
But what if I want it to evaluate the contents in that scalar as string expression? So I read into eval and I understand it to be meant to use to evaulate actual blocks of code. As in if an Eval block is just a regular block of code. So it returns all the same things a regular block would do. But according to my llama book, it states that it also has the advantage that it protects the primary source from errors. Especially if you're calling third party code and you don't have any assurance that it won't fail gracefully.
So now, I've run out of choice search phrases to try. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Resolving scalars in a scalar
by Zaxo (Archbishop) on Oct 30, 2003 at 03:40 UTC | |
by hardburn (Abbot) on Oct 30, 2003 at 14:42 UTC | |
by SavannahLion (Pilgrim) on Oct 30, 2003 at 05:44 UTC | |
by Roger (Parson) on Oct 30, 2003 at 06:16 UTC | |
by SavannahLion (Pilgrim) on Oct 30, 2003 at 08:29 UTC | |
by Roger (Parson) on Oct 31, 2003 at 03:56 UTC | |
|
Re: Resolving scalars in a scalar
by bart (Canon) on Oct 30, 2003 at 11:19 UTC | |
by SavannahLion (Pilgrim) on Oct 30, 2003 at 17:05 UTC | |
|
Re: Resolving scalars in a scalar
by etcshadow (Priest) on Oct 30, 2003 at 03:43 UTC | |
|
Re: Resolving scalars in a scalar
by Roger (Parson) on Oct 30, 2003 at 04:09 UTC | |
by SavannahLion (Pilgrim) on Oct 30, 2003 at 08:35 UTC | |
by Roger (Parson) on Oct 31, 2003 at 04:03 UTC |