in reply to Re: foreach(silly..japh)
in thread foreach(silly..japh)
is not exactly the same thing as$_= '.' . chr ord
Consider this:$_= '.'.$_
and then try to replace like this:${_} = q...q,.,.qq,$=,^q.$..$=; print ord() . "," foreach(split//);
for(;$_?$,:(${_} = q...q,.,.qq,$=,^q.$..$= => $_=q,.,.$_ );) {
It destroys the output (or should, at least). This is because ord returns the value of the first character in the string it is fed. There is a difference. If you replace all the way down to $_="\n" then it works again, of course. :)
For more clarity,
is reallyfor(s//Just another perl hacker/) {
foreach(s//Just another perl hacker/) {
- although they are interchangeable syntax-wise in perl.
I don't know if you used it, but sadly deparsing gives a lot away. What I do think is funny is that deparsing translates one for to while, one to foreach and leaves the last as a for:
Then again, I guess I am easily amused.while ($_ ? $, : ($_ = '.' . "$=" ^ '$' . $=, $_ = '.' . chr(ord $_))) + { foreach $_ (s// Just another perl hacker/) { (); } for (; s/.//; print $_) { (); } }
I like your initial reminder too - that was exactly what this was "about" - abusing the for construct, which is also a bit special in perl. :)
And oh, there is one more stripping possible to do - to get to approximately where I started (using your example):
Neither of the for loops has any real reason to be nested into any other - it is really just three separate lines of code.$_=".\n"; s//Just another perl hacker/; while (s/.//) { print; }
Thank you for taking the time - it is appreciated. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: foreach(silly..japh)
by domm (Chaplain) on Mar 06, 2002 at 12:55 UTC | |
by Dog and Pony (Priest) on Mar 06, 2002 at 13:22 UTC |