A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Use a string to make a variable name

my $rank10 = 42;
{
    no strict 'refs';
    my $num = 10;
    print eval "\$rank$num";
}


result:
    42

Bash profile settings

~/.bash_profile gets called when you log in for the first time. It's your user-specific settings.

~/.bashrc gets called when you start a new shell. Only interactive shells and user scripts read this file.

Type a literal tab in vi

If you've got "convert tabs to spaces" turned on, type this to insert a real tab:
Ctrl-V [tab]

Enjoy logging with Zend

Output to the page within Zend PHP engine:

$writer = new Zend_Log_Writer_Stream('php://output');
$logger = new Zend_Log($writer);
$logger->log('Enjoy this test', Zend_Log::DEBUG);

Or to the webserver error log:

$writer = new Zend_Log_Writer_Stream('php://stderr');
$logger = new Zend_Log($writer);
$logger->debug('Beginning log');

Beware of backslashes in login strings

using URI to parse an ftp connection string like:
ftp://domain\user:pass@host/path
...can lead to problems.
The backslash is not a legal URI character, so $uri->user may bring back just the domain!