« first day (126 days earlier)      last day (2441 days later) » 

08:42
@Zanna It is more that <> is patient when it appears in scalar context; it reads just one line. If there is something to read, you get a string that is that line; otherwise, you get undef. Really it reads one record, i.e., it stops after the input record separator: the value in $/, if any (see perldoc -v '$/'). If $/ is undef then <> "slurps" all input, as in that case there's just one record, but it's still reading just "one thing" in the sense of the scalar/list distinction.
08:56
Btw, I apologize for having said that $/ = "" works for slurping. That is totally wrong. Setting $/ to the empty string instead causes actual empty lines to be treated as record separators:
ek@Io:~$ perl -we 'local $/; while (<>) { chomp; print "[$_]\n" }' <<<$'foo\nbar\n\nbaz\n\n\nquux'
[foo
bar

baz


quux
]
ek@Io:~$ perl -we 'local $/ = ""; while (<>) { chomp; print "[$_]\n" }' <<<$'foo\nbar\n\nbaz\n\n\nquux'
[foo
bar]
[baz]
[quux]
09:15
So, sorry about that! Btw, TIL:
ek@Io:~$ perl -we 'print join q{}, q{a}..q{z}, q{0}..q{9}' | perl -wpe 'BEGIN { $/ = \6 } s/$/\n/'
abcdef
ghijkl
mnopqr
stuvwx
yz0123
456789
(The $/ = \6 part.)
 
10 hours later…
19:34
@Zanna Did you want to see what while (expression) is usually doing vs. what while (<>) is doing? I fully understand if you do not (it's a week-old conversation, after all!), or if you've already looked into this yourself.
I really do. I'm just waiting to be in the right sort of moment to read this properly. Since my parents are off work, I don't seem to have any solid periods of attention. I keep having to attend to something or be sociable. I'm not failing to participate in this conversation because of disinterest, but because I know I won't be able to understand it properly until I can give it sustained attention. I will definitely read all this properly soon.
I understand. Even if you were to choose not to continue with this conversation at all, I would not think of that as "failing to participate." Issuing forth huge wall of text, as I have done, is not exactly conversational, either. :)
If I talk about how while typically works, that will not require a prior reading of what was said before. But I still prefer to hold off on doing so until you're in a position to try out the code, such as with perl -e, or in reply, or by writing and running short Perl scripts. I would consider that more important than having read everything I said before. I don't know if you are in a position to do that right now, but my guess is that you may also be saying that you are not.
19:53
not right now, no :( probably this time tomorrow, or some time on Tuesday

« first day (126 days earlier)      last day (2441 days later) »