CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
What is different between the two expressions?

 



checkmate2001
stranger

Aug 15, 2001, 5:51 PM

Post #1 of 3 (244 views)
What is different between the two expressions? Can't Post

100 * (1 + 2**3) != (1 + 2**3) * 100?

try this
#!/usr/bin/perl

print 100 * (1 + 2 ** 3);
print "\n";
print (1 + 2 ** 3) * 100;



mhx
Enthusiast / Moderator

Aug 15, 2001, 9:34 PM

Post #2 of 3 (240 views)
Re: What is different between the two expressions? [In reply to] Can't Post

As always, perl's -w switch will tell you what's "wrong" with this:

Code
mholland@bmdke3 $ perl -we 'print 100*(1+2**3)' 
900
mholland@bmdke3 $ perl -we 'print (1+2**3)*100'
print (...) interpreted as function at -e line 1.
Useless use of integer multiplication (*) in void context at -e line 1.
9

So, never develop any code without -w.
Hope this helps.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"



checkmate2001
stranger

Aug 16, 2001, 1:59 AM

Post #3 of 3 (232 views)
Re: What is different between the two expressions? [In reply to] Can't Post

Thank u again, mhx
for your quick and accurate response :)


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives