Thank you, AnomalousMonk, for your very useful input.
Yes, looking at it retrospectively, I clearly realize that it was a bit silly on my part to try to pass a function invocation, rather than a simple code reference, to the benchmark module. I am definitely not proud of that stupid error, but I thought it might be useful to others for me to explain what I originally did wrong. I wrote a couple of tutorials in French on some specific uses of Perl, and, in them, I am quite often proposing an initial wrong answer before giving out the right one, as I think trying something wrong is at least as useful as getting the right one from the start. Your explanation on my original error serves the same purpose, thank you for that (and, let me be clear on that, I am not trying to claim that it will be useful to others only, my description of my original error was hopefully for the others' benefit, your explanation is useful to others, I think, AND to me as well).
My only excuse, if any, is that it was very late at night and I was tired, so that my ideas were a little bit blurred by tiredness (not to mention the couple of wine glasses I had earlier for a small celebration at my photo club). Then, as I already said, I was in a bit of a hurry to try to get the results I was looking for and wrapping the invocation in a sub {} construct was the fastest solution I found to get a clean compile and usable results. Thank you again for the time you took on this post, as well as on your earlier post on the same topic. Cheers.
| [reply] [d/l] |
... trying something wrong is at least as useful as getting the right one from the start.
I often see questions on this site in the form "What happens if I do X?" and the answer I am often tempted to give is "Well, what happened when you did X?" Unfortunately, this answer is usually a bit too brusque to offer a novice and one tends to be more circumspect. I agree that play is always valuable for learning, and Perl makes playful interaction fairly easy.
BTW: I didn't mean by my reply to offer you instruction for I do not suppose you need it, but only to offer a general explanation.
| [reply] |