[Courses] [Perl] Part 2: Scalar Variables

Dan dan at cellectivity.com
Mon Apr 11 18:41:04 EST 2005


> Below is my homework, please tell me if I'm sending this too early.

In fact, I think it would be better to wait 24 hours or so before 
sending your answers, just to give everyone a chance to think things 
over, regardless of time zone. Don't hurry for me, because I don't read 
my e-mail on weekends (which I know is unusual for a programmer.  :-)  )

But your answers are right on. This one is particularly insightful:

> Considering that the program output was SuzySuzySuzySuzy, the "x"
 > operator seems to concatenate a string with itself, as many
 > times as asked for (don't know if there is a proper english term
 > for that, but that operator is cool!)
> 
> I tried to think a bit about 4 x 'Suzy'. Perl has to know which is
 > the string and which is the "multiplicator". In that example it could
 > guess it, but what about 4 x 3? 4 x 3 outputs "444", but 3 x 4
 > outputs "3333". So operands need to be ordered.

-- 
  [Larry] Wall [inventor of Perl] believes that people think about
  things in different ways, that natural languages accommodate many
  mindsets, and that programming languages should too.
    - Jon Udell, in his essay, "A Perl Hacker in the Land of Python"


More information about the Courses mailing list