Do you know where your variables are? PerlMonks

### Re^2: Doomsday algorithm

by QM (Parson)
 on Sep 07, 2015 at 14:55 UTC ( #1141262=note: print w/replies, xml ) Need Help??

in reply to Re: Doomsday algorithm

To prove your point, when(5) duplicates "sunday".

And you probably want something like:

```@anchor_day_week = qw(tuesday wednesday thursday friday saturday sunda
+y monday)
[\$year_anchor_day+1..6,0..\$year_anchor_day];

...though I dislike repeating \$year_anchor_day. This just changes the repetition:

```push @anchor_day_week, splice @anchor_day_week, 0, \$year_anchor_day;

...so a function to do this for you would be appropriate, even if it's only used once.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^3: Doomsday algorithm
by soonix (Monsignor) on Sep 07, 2015 at 15:19 UTC
Yes, that's what I meant with "more elegant solution". The next step would be to further "normalize" that \$nbdays such that Sunday is the usual 0 or 7 (like in strftime %u or %w) by calculating
```my \$nbdays = (\$diff_to_doomsdates + \$year_anchor_day + 2) % 7; # or -5

Create A New User
Node Status?
node history
Node Type: note [id://1141262]
help
Chatterbox?
 [jedikaiti]: If I had a flying home, I'd be pretty psyched. How cool would that be? [jedikaiti]: The big question is, does it have autopilot? [shmem]: good autonomous flyer doesn't need a pilot.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2018-02-21 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When it is dark outside I am happiest to see ...

Results (285 votes). Check out past polls.

Notices?