I made a few changes, including substituting "unless" a couple of times, and changing the month hash to a list.
#!/usr/bin/perl #update: some problems with the month array in my code belo w (I was t +hinking the index starts at 1 not 0, newbie mistake. See discussion. use strict; use warnings; print "Excuse Generator\n\n\n"; my @myCities = ('Baltimore','Chicago','Los Angeles','New York','San Di +ego'); my $found=0; print "Please pick one of the following cities by entering any portion + of the beginning of the city name:(@myCities)\n"; chomp(my $input_city = <STDIN> ); if ( $input_city =~ m/^l/i ) { print "We no longer tour the city of Angels, please try again\ +n"; exit; } foreach my $city ( @myCities ) { if ($city =~ /^$input_city/i ) { $found = $city; print "Found $found\n"; next; } } unless ($found) { print "No City found!\n"; exit; } my @months = qw(January February March April May June July August Sept +ember October November December); print "Enter the month as an integer i.e. (1=January, 2=Febuary, etc.) +\n"; chomp(my $month = <STDIN> ); print "Invalid Month $month specified\n" unless (exists $months[$month +]); print "How many days [1-31]?\n"; chomp(my $num_days = <STDIN> ); #problems here, see discussion my $days = join( ", ", 1 .. $num_days ),; my @myArray = ( "\nHi Steve, \n\n", "I'm looking forward to the Perl class. \n", "I just want to let you know that I won't be in class on the f +ollowing days:\n\n", "\ $months[$month] $days\n\n", "I'm touring $found with my dance band, Liquid Blue!\n\n", "Thanks,\n", "Scott Stephens\n\n" ); print @myArray;

In reply to Re: **HomeWork** Printing the found input from an array by wrinkles
in thread **HomeWork** Printing the found input from an array by trenchwar

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.