Hi everyone,

I'm reading the modern perl book and I have some questions to address about
scalar and list context.

Here is the code that I want to understand.

while (<>) { chomp; say scalar reverse; }

Where I'm struggling is : say scalar reverse;

The book says that 'say' impose list context to Its operands. 'reverse'
impose list context on to its operands and treat them as a list in list
context and a concatenated string in scalar context.

The questions are:

Is 'say' that is imposing list context in 'reverse' or 'reverse' it self
treats it's operands in list context or it's both?

The most confusing part:
There is 'scalar' before 'reverse', so 'reverse' is evaluated in scalar
So how can reverse executing in both contexts (list and scalar context)?

I'm sure I missed something.

It will be great if I have more explanation.

Thank you.
Regards, Zakaria

Reply via email to