Developing software in the Real World

Prefixing every key in a hash ref in Perl

I needed to prepend some text to every element in a Perl hash ref, so I came up with:

which prefixes each key of $hashref with "prefix_". After talking it over with Cliff, he was concerned with modifying the list in place while simultaneously iterating over it and suggested this solution:

One interesting thing about this solution is the requirement for a unary "+" in map in order to help Perl work out… continue reading.

Missing mime-info database for use with File::MimeInfo

A requirement I have on a current project means that I need to determine the mime type of a file I load from disk. One way to do this is to use the File::MimeInfo::Magic CPAN module like this:

However, on OS X, an error was raised: WARNING: You don't seem to have a mime-info database. The shared-mime-info package is available from http://freedesktop.org/ . The easiest way to solve this is via Homebrew: