05 September 2022

Alphabetical and days hotter sentences

Alphabetical sentences

Why would you ever want to do this? Only Mohammad knows. The obvious logic, and the way I did it was:

  • Split the text into sentences
  • Split each sentence into an array of words
  • Sort the array
  • Print it out
In order to match Mo's sample output I limited the length of each output line to 60 chars, which adds a couple of lines to the script.

Hotter days

We've had a few hot days recently so this is topical and perhaps a little more practical than the sentences.

The obvious way to do it is to read the the data into an array such that $input{date} = temp, and then with 'for $date (sort keys @input) ' we can print the desired output in a single line of code.


No comments:

Post a Comment