Skip to Content
Perl One-Liners
book

Perl One-Liners

by Peteris Krumins
December 2013
Intermediate to advanced
168 pages
2h 49m
English
No Starch Press
Content preview from Perl One-Liners

Chapter 5. Working With Arrays and Strings

In this chapter, we’ll look at various one-liners for creating strings and arrays, for doing things like generating passwords, creating strings of certain length, finding the numeric values of characters, and creating arrays of numbers. You’ll also learn about the range operator .., the x operator, the $, special variable, and the @ARGV array.

5.1 Generate and print the alphabet

perl -le 'print a..z'

This one-liner prints all letters from a to z in the English alphabet as abcdefghijklmnopqrstuvwxyz. The letters are generated by the range operator .., which, when used on strings in the list context (provided here by print), applies the magical auto-increment algorithm that advances the string to the next ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Best Practices

Perl Best Practices

Damian Conway
Perl Cookbook

Perl Cookbook

Tom Christiansen, Nathan Torkington
Minimal Perl

Minimal Perl

Tim Maher
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9781457185281Errata