Dear Monks--
Sorry if I haven't provided enough information

O.K. Here is all the code I can think is relevant. You wanted to know what line was generating the error ("Modification of a read-only value attempted"). It was the last line I'm giving here; i.e. the sort line. Is it worth noting that elsewhere in the program I am able to access any element of the @courselist array without problem?
foreach $try (@text){ $try =~/^(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?) +\|(.*?)\|(.*?)$/gs or die "<br />problem with $try<br />"; my $Institution = $1; my $CourseNumber = $2; my $Professor = $3; my $Enrollment = $4; ........ if (!$CourseNumber && !$Institution){last;}; if ($CourseNumber ne $LastCourseNumber){ $courseindex = $courseindex + 1; $courselist[$courseindex] = [$Institution, $CourseNumber, $Professor, +$CourseTitle, $Enrollment]; }; $LastCourseNumber = $CourseNumber; }; @courselist = sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @co +urselist;
To reiterate, what I'd like to do is to sort @courselist by $courselist[n][0] (i.e. $Institution, and within that sort, by $courselist[n][1], i.e. $CourseNumber.

This is an example of what I have in @courselist:
$courselist[0] = ["UM", "CS 34", "Smith", "34"] $courselist[1] = ["AC", "PHIL 13", "Barry", "45"] $courselist[2] = ["UM", "BIO 567", "Houlihan", "12"]
and I want it to end looking like this:
$courselist[0] = ["AC", "PHIL 13", "Barry", "45"] $courselist[1] = ["UM", "BIO 567", "Houlihan", "12"] $courselist[2] = ["UM", "CS 34", "Smith", "34"]

I don't understand why I'm getting the error message, and I'm still not sure about the sort...

Thanks for your continuing efforts!

In reply to Re: How to fix error: Modification of a read-only value by Gnat53
in thread How to fix error: Modification of a read-only value by Gnat53

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.