55

Variables
List Range Operator

  • Since it is common to reference a range of values (either as data values or as index values), Perl defines a special list range operator ".." to simplify the specification of such a range

  • The ".." operator is used as an infix operator placed between any two scalar values

  • Perl will interpolate the (quantized "in between") values automatically
      ( 1..5 )          # Yields ( 1, 2, 3, 4, 5 )
      
      ( 1.3..6.1 )      # Yields ( 1.3, 2.3, 3.3, 4.3, 5.3 )
      
      ( 2..6, 10, 12 )  # Yields ( 2, 3, 4, 5, 6, 10, 12 )
      
      ( "a".."z" )      # Yields ( "a", "b", "c", ..., "z" )  Nice.
      
      ( "a1".."e9" )    # Yields ( "a1", "a2", ..., "e9" )    Wow!