perl q[..] range operator

there are 2 largely unrelated operators:

  • list range-operator,
  • scalar range-operator

#1 most common usage (list context) iterates over a range of integers or strings, similar to python xrange(). [1] has clear examples.

#2 (possibly more powerful) usage is during text file line-by-line processing. The operator selects a continuous chunk of lines.  Un-intuitively, this is considered scalar context. [1] has useful example, but need to understand the basics first.

#2b simplest use cases has two hardcoded numbers.

[1] Overall, this article has too many technicalities to obscure the key, useful features.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s