Skip to Content
Perl 6 Deep Dive
book

Perl 6 Deep Dive

by Andrew Shitov
September 2017
Beginner
402 pages
9h 52m
English
Packt Publishing
Content preview from Perl 6 Deep Dive

String logical operators

These operators are the logical operators over strings. They start with the ~ character to follow the general idea that string operations use a tilde. The ~&~|, and ~^ operators do the AND, OR, and XOR operations respectively.

Before the bitwise operation, both operands are converted into the string representation (if necessary). Then, the operation is executed over the corresponding bits.

Let's consider an example of how to make the ASCII alphabetic character lowercase. In ASCII, the difference between the code of the lowercase and uppercase letter is 32 (0x20 in hexadecimal notation). So, to make the letter lowercase, execute a ~| operation on it and 0x20, which is the code of space, to set the fifth bit to 

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 Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Learning Perl 6

Learning Perl 6

brian d foy
Think Perl 6

Think Perl 6

Laurent Rosenfeld, Allen B. Downey
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 9781787282049Supplemental Content