101
SOLUTION MEGATHREAD-π- 2022 Day 2 Solutions -π-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 4 days, 4 hours after) by daggerdragon to /r/adventofcode (134.8k)
NEW AND NOTEWORTHY
- All of our rules, FAQs, resources, etc. are in our [community wiki](/r/adve...
since 3 years, 1 month ago
3 of 3
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


Thanks. It's great your on Perl v5.36, because that makes function parameters really easy.
First, for backwards-compatibility reasons, you need to tell Perl that you're using the latest syntax. Start your program with:
However,
v5.36automatically enables strict and warnings for you, so in place of adding thev5.36line you you can remove those two.βThen just declare functions like:
or:
and Perl will handle the parameters for you.
β Starting your Perl programs with the minimum version number required also means it will check for that and give a sensible error message if somebody attempts to run it on an older version of
perlβ which is much better than it just failing weirdly on syntax is doesn't recognize. And in forums like this one, it provides documentation for humans, rather than them having to guess which version ofperlthey need to run.oh yeah, I remember I tried using given() { when...} and I was wondering why Perl simply refused to parse my thing. what's the "default" version if I don't have that use there?
I think the first syntax changes were brought in with
v5.10, so the βdefaultβ semantics are probably something likev5.8.2β ancient history, anyway!