SPUG: scalar(@array)
El JoPe Magnifico
jope-spug at n2h2.com
Thu Apr 13 18:49:23 CDT 2000
Or if count isn't too high (so that the temporary array created isn't
too large - yeah, yeah, messy programming) you can use the one-liner...
$count = grep defined, @array;
Or for the neat freaks out there (even I have my days =)...
$count = scalar( grep( defined($_), @array ));
On Thu, 13 Apr 2000, Jeremy Mates wrote:
> The count you were probably expecting to see can be gained by doing
> something like:
>
> for ( @array ) {
> $count++ if defined;
> }
> print $count, "\n";
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
Email to majordomo at pm.org: "action" spug-list your_address
More information about the spug-list
mailing list