Blame


1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
2 ffd9a51f 2023-08-04 jrmu
3 ffd9a51f 2023-08-04 jrmu #Write a program that reads a list of strings (on separate lines) until end-of-input. Then it should print the strings in code point order. That is, if you enter the strings fred, barney, wilma, betty, the output should show barney betty fred wilma. Are all fo the strings on one line in the output or on separate lines? Could you make the output appear in either style?
4 ffd9a51f 2023-08-04 jrmu #
5 ffd9a51f 2023-08-04 jrmu use warnings;
6 ffd9a51f 2023-08-04 jrmu use strict;
7 ffd9a51f 2023-08-04 jrmu use utf8;
8 ffd9a51f 2023-08-04 jrmu
9 ffd9a51f 2023-08-04 jrmu my @names = qw(fred betty barney dino wilma pebbles bamm-bamm);
10 ffd9a51f 2023-08-04 jrmu print "Type numbers from 1-7, one on each line. Once finished, type ^d:\n";
11 ffd9a51f 2023-08-04 jrmu chomp(my @numbers = <STDIN>);
12 ffd9a51f 2023-08-04 jrmu foreach (@numbers) {
13 ffd9a51f 2023-08-04 jrmu print "$names[$_-1]\n"
14 ffd9a51f 2023-08-04 jrmu }