About operator “x” in Perl

  • A+

I am confused by the following output of the code:

print "1234567890" x (10+9)/10; 

The output is


I know the code should be this in order to get the intended result:

"1234567890" x ((10+9)/10) 

But why does the former code generate a float number but not a string? Isn't the operator "x" a string operator in Perl?


x is a string operator, but you are using / on the string it produces, which numifies "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678912345678901234567890123456789012345678901234567890" and divides it by 10.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: