Category Archives: midweek bonus item

Some special Unicode shell aliases to normalize strings

If you are playing with Unicode, you’re probably going to want to convert to the various normalization forms. There are some programs to do this in the Unicode::Tussle distribution, but you can also create some one-liners to do this as well (Item 120. Use Perl one-liners to create mini programs). If you want to read […]

Find dates with Regexp::Common

[This is a mid-week bonus item] Suppose you want to find some dates inside a big string. The problem with dates is that there are some many ways to write them, and even if you can come up with a pattern to get the structure right, can you handle the different locales and languages that […]

Use Regexp::Common to find locale-specific dates

[This is a mid-week bonus item, and it's a bit of a departure from much of what you have already seen on this blog. This is just some code that I had to write this week and I thought you'd like to see it.] I had to find some dates inside a big string, and […]

Perl 5.14 adds non-destructive transliteration

[This is a mid-week bonus item since it's so short] In Perl 5.13.2, you got a non-destructive version of the substitution operator (Use the /r substitution flag to work on a copy). Instead of changing it’s target, the non-destructive version returns a new string that has the substitution. Perl 5.13.7 extends the /r to work […]

Force install a module to reinstall it

[This is a midweek bonus Item since it is so short] I recently bought the new MacBook Air, which means my solid state device has over four times the storage as my old MacBook Air. For the first time, I used Apple’s migration tool to transfer everything from the old one to the new one. […]

Use the return value from srand

[This is another bonus, mid-week item since it's so short and probably mostly useless as a tweak to what you already do.] Perl 5.14 changes srand to return the seed that it used to start the pseudorandom number generator that gives you numbers through rand. There are plenty of interwebs that will explain the difference […]

Set default values with the defined-or operator.

[This is a mid-week bonus Item since it's so short] Prior to Perl 5.10, you had to be a bit careful checking a Perl variable before you set a default value. An uninitialized value and a defined but false value both acted the same in the logical || short-circuit operator. The Perl idiom to set […]

7ads6x98y