[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] arithmetic within a string?




Paul N. Schatz wrote:

> $do = 3.4*5.6;
> print "3.4*5.6 = $do\n"; # gives 3.4*5.6 = 19.04
> ****************
>         Am I correct that there is no way to have the arithmetic occur
> within the string?

    ##  In this way you only have to   t y p e   t h e   t e r m   o n c e :

$term1 = "3.4 * 5.6";
print "$term1 = ", eval $term1;
    ##  or:
print $term2 = "\n3.4 * 5.6", " = ", eval $term2;
    ##  Both will print:   3.4 * 5.6 = 19.04


Detlef Lindenthal <detlef@lindenthal.com>


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org