in reply to Re: grep usage confusion
in thread grep usage confusion

grep returns a list. In scalar context (my $index = ... for example) a list returns the count of elements in the list.
No, it doesn' work that way. There is no list in scalar context - it is, afterall, scalar context. Lists only exist in list context. It is grep that returns the number of matches in scalar context.

If it were true that functions returned lists, and lists in scalar context return the count of elements, then none of the following would work the way they do now:

my $formatted_time = localtime; my $last_element = (10, 11, 12); my $package = caller; my $success = stat "/etc/passwd"; ...