in reply to Re: Re: Need counter assistance
in thread Need counter assistance

Perl has a concept called "context". Different functions or constructs return different things depending on whether they're called in a list (or array) context or a scalar context.

For example, you could have just said

my $ct=@files;
and $ct would have been set correctly, because that assignment is a scalar context, and in a scalar context an array or list returns its number of elements.

Since "print" is a list context, I had to use the "scalar" operator to get the count of elements rather than the list of values.

Check out "perldoc -f scalar" and "perldoc perldata" for more information.
--
Mike

Replies are listed 'Best First'.
Re: Re: Re: Re: Need counter assistance
by Anonymous Monk on Aug 30, 2002 at 14:01 UTC
    Thanks for your answers and quick responses!