in reply to Using $# defines a variable?

Hello smittypaddler,

Some notes:

  1. Obligatory reference on autovivification: Autovivification: What is it and why do I care? by Uri Guttman
  2. $#{$array} can be written more simply without the braces: $#$array
  3. The CPAN module autovivification can be used to disable this behaviour:
    use strict; use warnings; no autovivification; my $array; warn sprintf 'array is%s defined', defined $array ? '' : ' not'; warn '$#$array is ', $#$array; warn sprintf 'array is%s defined', defined $array ? '' : ' not';

    Output:

    13:28 >perl 1999_SoPW.pl array is not defined at 1999_SoPW.pl line 7. Can't use an undefined value as an ARRAY reference at 1999_SoPW.pl lin +e 8. 13:28 >

Hope that’s of interest,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,