Re: Statement modifier thingie
by BrowserUk (Patriarch) on Mar 01, 2012 at 04:39 UTC
|
This has the affect you want, at least for the example supplied:
print join "\n", 1..3, "\n";;
1
2
3
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
| [reply] [d/l] |
|
|
I think that's three people saying "Give it up, Keith; she's dead, buried, forgotten, and even the life insurance money's all been drunk up." All righty, then - thanks, all you wise Perl Monks!
| [reply] |
|
|
| [reply] |
Re: Statement modifier thingie
by davido (Cardinal) on Mar 01, 2012 at 06:00 UTC
|
It's not a statement modifier, but it is a "loopy thing".
print( ( map { "$_\n" } 1 .. 3 ), "\n\n" );
...but why?
| [reply] [d/l] |
Re: Statement modifier thingie
by Anonymous Monk on Mar 01, 2012 at 03:57 UTC
|
| [reply] [d/l] |
|
|
'K, I'll try to say it a different way: is there a way for me to use a
statement modifier like print "$_\n" for 1..3 and add
something to the end of it, like an extra newline, that doesn't mess with
the loop but just gets printed after it? I've tried parens, brackets,
commas, the dot, and mayonnaise with ketchup smeared nice and even, but
none of it works (and some is pretty messy.) Is there a way to do it?
| [reply] [d/l] |
|
|
| [reply] |
|
|
|
|
Re: Statement modifier thingie
by rovf (Priest) on Mar 01, 2012 at 10:51 UTC
|
| [reply] [d/l] |
|
|
Yeah, statements are constructs like:
if ($foo) {print "Hello"};
package Foo 1.2.3;
use Hello;
{ 1 }
next if $bar;
None of those can receive a "statement modifier".
In fact, if you inspect perly.y you'll see that expressions are modified:
sideff : error
| expr
| expr IF expr
| expr UNLESS expr
| expr WHILE expr
| expr UNTIL iexpr
| expr FOR expr
| expr WHEN expr
;
with sideff one of the many forms of statements.
If you're going to reply with irrelevant snobbery, please aim for the middle of the bowl instead of peeing all over the stall.
And think what exactly is a "statement" in Perl! | [reply] [d/l] [select] |
|
|
In fact, if you inspect perly.y you'll see that expressions are modified:
Interesting! Hence, a statement modifier turns an expression in a statement. Didn't expect this.
BTW, my comment was not intended as snobbery, but because I concluded that statement modifiers are never part of a sub-expression (as the OP wanted to use them). In any case, your comment is appreciated.
--
Ronald Fischer <ynnor@mm.st>
| [reply] [d/l] |
|
|
| [reply] |