You are reading the article written before the rename. What is said here, most likely still works, but you may want considering to review the differences after the rename. The texts published on this site prior to the rename will stay unchanged for reflecting the historical truth.

In October 2019, Perl 6 has been renamed to Raku. Its grammar, syntax, sigils, and everything remain the same, but when reading this article, please read Perl 6 as Raku .

N. B. Perl 6 has been renamed to Raku. Click to read more.

There is a new version of this book. If you want to get an electronic copy or a paperback, see Using Raku for more details.

100 Programming Challenges Solved with the Perl 6 Programming Language

This book is a collection of different programming challenges and solutions in Perl 6. It can be used as an exercise book, when you are learning Perl 6, or as a reference book when you are teaching it.

It is assumed that the reader knows thebasics of Perl 6 and wants to have some practice.

Andrew Shitov. Using Perl 6

© Andrew Shitov, author, 1 November 2017

Published on perl6.online in September 2019

Published by DeepText, Amsterdam

www.deeptext.media

ISBN 978-90-821568-1-2

Navigate to the contents below or download the PDF version.

Book Contents

Introduction

How to debug Perl 6 programs

Part 1

Chapter 1. Strings

1.1. Using strings

1. Hello, World!

2. Greet a person

3. String length

4. Unique digits

1.2. Modifying string data

5. Reverse a string

6. Removing blanks from a string

7. Camel case

8. Incrementing filenames

9. Random passwords

10. DNA-to-RNA transcription

11. Caesar cipher

1.3. Text analysis

12. Plural endings

13. The most frequent word

14. The longest common substring

15. Anagram test

16. Palindrome test

17. The longest palindrome

18. Finding duplicate texts

Chapter 2. Numbers

2.1. Using numbers

19. π

20. Factorial!

21. Fibonacci numbers

22. Print squares

23. Powers of two

24. Odd and even numbers

25. Compare numbers approximately

26. Multiplying big numbers

27. Prime numbers

28. List of prime numbers

29. Prime factors

30. Reducing a fraction

31. Divide by zero

2.2. Random numbers

32. Generating random numbers

33. Neumann’s random generator

34. Histogram of random numbers

2.3. Mathematical problems

35. Distance between two points

36. Standard deviation

37. Polar coordinates

38. Monte Carlo method

2.4. Numbers and strings

39. Unicode digits

40. Guess the number

41. Binary to integer

42. Integer as binary, octal, and hex

43. Sum of digits

44. Bit counter

45. Compose the largest number

46. Convert to Roman numerals

47. Spelling numbers

Chapter 3. Aggregate Data Types

3.1. Manipulating lists and arrays

48. Swap two values

49. Reverse a list

50. Rotate a list

51. Randomise an array

52. Incrementing array elements

53. Adding up two arrays

54. Exclusion of two arrays

3.2. Information retrieval

55. Sum of the elements of an array

56. Average of an array

57. Moving average

58. Is an element in a list?

59. First odd number

60. Take every second element

61. Number of occurrences in array

62. Finding unique elements

63. Minimum and maximum

64. Increasing sequences

3.3. Working with subroutines

65. Passing arrays to subroutines

66. Variadic parameters in a sub

3.4. Multi-dimensional data

67. Transpose a matrix

68. Sort hashes by parameter

69. Count hash values

70. Product table

71. Pascal triangle

Chapter 4. Regexes and Grammars

4.1. Regex matching

72. Count vowels in a word

73. Count words

74. Skipping Pod documentation

75. Currency converter

4.2. Substitutions with regexes

76. Double each character

77. Remove duplicated words

78. Separate digits and letters

79. Separate groups of digits

80. Increase digits by one

81. Pig Latin

82. Simple string compressor

83. %Templating% engine

4.3. Using grammars

84. Decode Roman numerals

85. Balanced parentheses

86. Basic calculator

Part 2

Chapter 5. Date and Time

87. Current date and time

88. Formatted date

89. Datetime arithmetic

90. Leap years

Chapter 6. Parallel Computing

91. Setting timeouts

92. Sleep Sort

93. Atomic operations

94. Parallel file processing

Chapter 7. Miscellaneous

95. The cat utility

96. The uniq utility

97. Reading directory content

98. Text to Morse code

99. Morse to text

100. Brainfuck interpreter

Keep experimenting and make your way in running the Perl 6 code in production applications!

The book was published in the end of 2017 in paper and later as e-book, and was published online at perl6.online in the end of 2019.

The content on this page is free of charge and may be used for any educational purposes. See more books from me at deeptext.media.