How to use print "The answer is "$cnt1+$cnt2; in Perl?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
Hi all,

I am a Perl newbie.

$cnt1 = 2;
$cnt2 = 3;

And I want to directly
Code:
print "The answer is "$cnt1+$cnt2;

The above code have compile error. How to mix the string and +/-/*/... ... without middle parameter?

How to do it?

Best regards,
Davy
 


    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Simple Perl Problem?

Probably you need ","
print "The answer is ", $cnt1+$cnt2;

Nandy
www.nandigits.com
Netlist Debug/ECO in GUI mode.
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…