Paul Harwood wrote:
>
> I am reading through a book on Objects and References and I don't
> understand this statement:
>
> $sum +=  $_ for split //;
>
> I thought a FOR statement needed to be in braces. How is it being used
> in this context?

Hi Paul.

In this instance 'for' is working as a statement 'modifier'. This
is from 'perldoc perlsyn':

    Any simple statement may optionally be followed by a *SINGLE* modifier,
    just before the terminating semicolon (or block ending). The possible
    modifiers are:

        if EXPR
        unless EXPR
        while EXPR
        until EXPR
        foreach EXPR

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to