chomp your input. The trailing newline is giving you the problems you're attributing to quotes.

Line 7 probably takes a much bigger bite than you need. The td and style attributes have nothing to do with your assignment. But, OTOH, you might like to say:
$html =~ m{$date(.*?)(?=</tr>)}gms;
to make sure you get the whole mess.

Did /me just call that assignment page a mess? Yep! It appears that the maker is using MS Word (or possibly, some other M$, gefuksperated generator of HTML) producing excessively verbose, unnecessarily obscure code. You have my sympathy, because the best you'll get directly from this site is something like this:

977707.pl What day? 4/24/012 Wide character in print at D:\_Perl_\pl_test\977707.pl line 14, <> lin +e 1. <o:p></o:p></span></p> </td> <td width="85%" valign=top style='width:85.66%;border:none;backgroun +d:white; padding:.75pt .75pt .75pt .75pt'> <p class=MsoNormal style='tab-stops:decimal .5in left 109.85pt'><b style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt'>A +P Exam-<span class=SpellE>ish</span> Test, Part IA (multiple <span class=GramE>ch +oice</span>, no calculator).</span></b><span style='font-size:10.0pt'> We will st +art at 7:55 sharp: 28 questions in 55 minutes.<br> <br> HW due (will not be collected until next week): another 70 minutes&# +915;اض worth of AP review problems, double dose over the long weekend.<o:p></o:p></s +pan></p> </td> <td width="3%" style='width:3.12%;border:none;padding:0in 5.4pt 0in +5.4pt'> <p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p>< +/span></p> </td>

Dealing with the encoding that produces the initial "wide character" report would be trivial, but getting rid of the proprietary tags and css will be a major PITA.

FTR, the following code produced the above output but it still has problems -- such as the omission of a line to IMMEDIATELY assign the value in $1 to a named $var and the uninformative and misleading message in your or die:

#!/usr/bin/perl use 5.014; use LWP::Simple; print "What day? "; my $date = <>; chomp $date; my $url = 'http://staweb.sta.cathedral.org/departments/math/mhansen/pu +blic_html/1112hcal/1112hcal.htm'|| die "Specify URL in the form 'm/dd +/0yy'"; my $html = get ($url); $html =~ m{$date(.*?)(?=</tr>)}gms; print "$1 \n";

And BTW, this smells even more like homework, now, given the assignment date is nearly 2 months past.


In reply to Re: Insert a variable without quotes by ww
in thread Insert a variable without quotes by LaneM1234

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.