in reply to Trying to make a simple countdown timer
G'day maxamillionk,
"... the code below does something quite different from what I expect."
Without telling us what you expected to happen and what actually happened, we're left entirely with guesswork.
This code runs for me. It does not produce any exception messages. It does what I'd expect it to do.
I'm sort of making a point there: you have no idea what my exceptionsexpectations were. :-)
Try adding another statement near the top (without changing anything else):
... use strict; $| = 1; ...
Does that now do what you expect? If so, your problem was buffering.
Depending inon your real requirements — beyond what you have in this tiny, demo script —
there's possibly better ways to handle this:
see "perlvar: $|", "IO::Handle"
and "Suffering from Buffering?".
For future reference, please read "How do I post a question effectively?" and (related but probably not particularly useful in this specific instance) "SSCCE".
Nothing to do with the issue at hand; however, I thought I'd point out that &main is probably not what you want here. Unless you really want it, and know exactly why you want it, choose subname() over &subname. See perlsub for more about that.
Update:
Fixed typos:
s/my exceptions/my expectations/ — thanks roboticus.
s/Depending in/Depending on/ — noticed when fixing the previous typo.
— Ken
|
|---|