You can use the following way also. Code: my @arr ; if ( @arr ) { print "Array not empty\n"; } else { print "Array empty\n"; } There is no need to use the scalar function. By default this will be treated as scalar context
Another way to test whether a list is empty is as follows Code: my @arr ; if ( $#arr== -1 ) { print "Array not empty\n"; } else { print "Array empty\n"; } $# will contain the index value of a list. If a list is not having any value means this will be -1. If a list is having only one element means this will be 0 and so on.