On 20/01/2012 13:51, Shawn H Corey wrote:
On 12-01-19 11:08 PM, Andrey P wrote:
I don't understand why I need to use a list assignment for
say scalar(()=<$fh>);
but not for
say scalar(grep /./,<$fh>);
These are not the same. Try this instead:
say scalar( grep /^/, <$fh> );
Or even simply
On 12-01-19 11:08 PM, Andrey P wrote:
I don't understand why I need to use a list assignment for
say scalar(()=<$fh>);
but not for
say scalar(grep /./,<$fh>);
These are not the same. Try this instead:
say scalar( grep /^/, <$fh> );
--
Just my 0.0002 million dollars worth,
2012/1/20 Andrey P
> Hi!
> I don't understand why I need to use a list assignment for
>say scalar(()=<$fh>);
> but not for
>say scalar(grep /./, <$fh>);
>
Because grep gives a list context to its second operand, just like the nuke
( ()= ) operator does. )
Remember, a context is what's
On Fri, 20 Jan 2012 10:08:31 +0600, Andrey P wrote:
> I don't understand why I need to use a list assignment for
>
> say scalar(()=<$fh>);
>
> but not for
>
> say scalar(grep /./, <$fh>);
>
> From perlop:
>
> If a is used in a context that is looking for a list, *a
> list* comprising al
Hi!
I don't understand why I need to use a list assignment for
say scalar(()=<$fh>);
but not for
say scalar(grep /./, <$fh>);
>From perlop:
If a is used in a context that is looking for a list, *a
list* comprising all input lines *is returned*, one line per list
element.
>From perlfun