in reply to Re: How to iterate thru entire array with start point other than beginning
in thread How to iterate thru entire array with start point other than beginning
I spoke too soon. I'm actually a little stumped on the % modulo operator and the example. I see a lot more than 12 months being printed out. The goal is to start with current month +1 (so October if using today in the example) and then print the 12 months in order from there..
#!/usr/bin/perl use POSIX 'strftime'; use strict; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; my $curr_mth = sprintf "%2d", strftime('%m', $sec,$min,$hour,$mday,$mo +n,$year,$wday,$yday,$isdst); my @month_name = qw(January February March April May June July August +September October November December); for my $m ( 0 .. $#month_name) { print "Month name is: $month_name[$m]\n"; }
I'm trying to get out as follows:
Month name is: October Month name is: November Month name is: December Month name is: January Month name is: February Month name is: March Month name is: April Month name is: May Month name is: June Month name is: July Month name is: August Month name is: September
then next month the output would be:
Month name is: November Month name is: December Month name is: January Month name is: February Month name is: March Month name is: April Month name is: May Month name is: June Month name is: July Month name is: August Month name is: September Month name is: October
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to iterate thru entire array with start point other than beginning
by hippo (Archbishop) on Sep 01, 2016 at 21:06 UTC | |
by dirtdog (Monk) on Sep 02, 2016 at 00:40 UTC | |
|
Re^3: How to iterate thru entire array with start point other than beginning
by dirtdog (Monk) on Sep 01, 2016 at 19:36 UTC | |
by planetscape (Chancellor) on Sep 02, 2016 at 15:48 UTC |