in reply to Re^8: chopping a string into slices - is there a more elegant way to do it?
in thread chopping a string into slices - is there a more elegant way to do it?
I confess that I was (for reasons unknown) expecting 'x' to do listy things in List Context and scalary things otherwise
I recall the developers of Perl a bit ashamed of that one. I don't know if it was done that way for backwards compatibility or if it was simply a case of the consequences not being anticipated. It really does break the mold.
Similarly, of course, foreach VAR (LIST) BLOCK reenforces the feeling that '()' have something to do with the making of lists.
Really?
for (foo()) { bar() } # List while (foo()) { bar() } # Scalar if (foo()) { bar() } # Scalar print(foo()) # List length(foo()) # Scalar
I even use for as a topicalizer regularly.
for ($var) { # Scalar s/^/[/; s/$/]/; }
The purpose of parens in flow control statements in Perl5 is purely decorative. However, their roots are in C, where their purpose is for precedence.
|
|---|