in reply to Re^2: Slices from array reference
in thread Slices from array reference

Update: Hmf! I guess after 4300+ posts I'm entitled to an accidental duplicate. But I do apologize for the inconvenience.

If you hate "magic numbers" appearing scattered throughout a script, you can use enum to set up constants with similar syntax to C:

# At the top of the script... use enum qw( YR=0 MO DM DY=7 WK ); # ...later... my( $yr, $mo, $dm, $dy, $wk ) = @{$values}[ YR, MO, DM, DY, WK ];

The same effect can be achieved with the constant pragma, though the setup is a little less convenient.


Dave