On 5/5/05, Terrence Brannon <[EMAIL PROTECTED]> wrote: > I was looking at a line in the hangman program: > > @letters == @solution.grep:{ $_ ne '' }; > > and was told that I was looking at an adverbial block. > > But I don't understand what that is and could not find a description > and examples in a reverse search on dev and nntp.perl.org.
Methods with arguments require parens. However, the block to grep isn't I<really> an argument. It's describing the manner in which the array will be grepped... that's an adverb to grep. So, why are the parens required on methods? Take the following if statements: if @foo.shift { ... } if @foo.grep { ... } # grep doesn't get the block To make things clear, methods without parens are assumed to take no arguments. In order to pass a block to the above grep, you either need to use @foo.grep({ $^a <=> $^b}) or the adverbial colon: if @foo.grep:{$^a <=> $^b} { ... } Ashley Winters