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

In reply to Re^2: How to iterate thru entire array with start point other than beginning by dirtdog
in thread How to iterate thru entire array with start point other than beginning by dirtdog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.