[Israel.pm] List of all contexts in Perl

Mikhael Goikhman migo at homemail.com
Sat May 29 14:56:46 PDT 2010


On 30 May 2010 00:03:57 +0300, sawyer x wrote:
> 
> I could not find a context list in Perldoc but that doesn't it mean
> it doesn't exist.
> 
> The contexts that I know are scalar context, list context, boolean
> context (if(), while()), void context ($var;) and intepolative
> context ("$var").

I would add at least numeric context to this list, activated when
arithmetical operators are used. There are others, for example
assignment context.

"perldoc overload" provides some enlightenment on the topic.
Basically every group of operators described in this document can be
(but not required to be) seen as a separate context. This includes:

  * Arithmetic, Comparison, Bit operations
  * Boolean, string and numeric conversion: 'bool', '""', '0+'
  * Iteration: '<>'
  * Matching: '~~'
  * Dereferencing: '${}', '@{}', '%{}', '&{}', '*{}'

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'


More information about the Perl mailing list