Skip to Main Content
Programming Perl, 3rd Edition
book

Programming Perl, 3rd Edition

by Larry Wall, Tom Christiansen, Jon Orwant
July 2000
Intermediate to advanced content levelIntermediate to advanced
1104 pages
35h 1m
English
O'Reilly Media, Inc.
Content preview from Programming Perl, 3rd Edition

use locale

@x = sort @y;       # ASCII sorting order
{
    use locale;
    @x = sort @y;   # Locale-defined sorting order
}
@x = sort @y;       # ASCII sorting order again

This lexically scoped pragma tells the compiler to enable (or disable, under no locale) the use of POSIX locales for built-in operations. Enabling locales tells Perl's case-conversion functions and pattern-matching engine to be respectful of your language environment, allowing for characters with diacritical markings, etc. If this pragma is in effect and your C library knows about POSIX locales, Perl looks to your LC_CTYPE setting for regular expressions and to your LC_COLLATE setting for string comparisons like those in sort.

Since locales are more a form of nationalization than of internationalization, the use of locales may interact oddly with Unicode. See Chapter 15 for more on internationalization.

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

Mastering Perl, 2nd Edition

Mastering Perl, 2nd Edition

brian d foy
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes
Perl in a Nutshell, 2nd Edition

Perl in a Nutshell, 2nd Edition

Nathan Patwardhan, Ellen Siever, Stephen Spainhour

Publisher Resources

ISBN: 0596000278Supplemental ContentErrata