Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Using $# defines a variable?

by Athanasius (Archbishop)
on May 19, 2019 at 03:33 UTC ( [id://11100236]=note: print w/replies, xml ) Need Help??


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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11100236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found