Re: regex, number of matches



Dr.Ruud wrote:
>
> What I found hard to get, is the role of the '()' in the wc-words-line:
>
> $ret[1] += () = /\S+/g; # words
>
> After a while, I understood it as an anonymous array that is filled with
> the matches, after which its length is used to increase the words-count.

If it had been an anonymous array it would have been:

$ret[1] += @{[ /\S+/g ]}; # words



John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Re: hash of arrays
    ... which works on Strawberry Perl and Linux Perl: ... Because of Perl's dereferencing and precedence rules. ... second element of the @value array. ... the anonymous array referenced by the scalar $value. ...
    (comp.lang.perl.misc)
  • Re: Disappointed by perl..
    ... There is this "sub variable scope" thing, ... Perl has block scoped lexicals, which can easily be used for sub scopes, ... I dont understand why pop couldnt work on an anonymous array returned by ...
    (comp.lang.perl.misc)
  • Re: Conserving memory
    ... Is the memory that was used for that anonymous array now freed? ... OS-memory allocated by perl gets detached ... from a container when the container itself is ...
    (perl.beginners)
  • Re: Current directory?
    ... John ... use Perl; ... Prev by Date: ...
    (perl.beginners)
  • Re: How to check if a file is exist or not?
    ... John ... use Perl; ... Prev by Date: ...
    (comp.lang.perl.misc)