alvin's blog

Perl - How to compare a string against multiple patterns

For a Perl program that I'm working on right now, I need to match the elements of an array of strings against several patterns, and then take an action if the current string matches one of my patterns. This is pretty easy in this case, in part because it's easy to match a string against multiple patterns in Perl, and also because my patterns are very simple -- no regular expressions involved.

Perl array size/length - How to determine the size of a Perl array

A frequently asked question Perl question is "How do I determine the size/length of a Perl array?", or the equivalent "How do I determine how many elements are in a Perl array?"

There are at least three different ways to do determine the Perl array size/length. Here's some Perl source code that shows these three Perl array size approaches:

Perl true and false - What is true and false in Perl?

Perl true/false FAQ: What is true in Perl? What is false in Perl?

The Perl programming language is a little unusual in not having true and false boolean operators. Because of this, I can never seem to remember what equates to true and false in Perl, so I decided to create this page.

What is true/false in Perl

In short, the following elements evalue to false in Perl:

Perl comparison operators

Perl equality FAQ: Can you share a list of the Perl equality operators?

Sure. Here's a convenient list of the Perl comparison operators (also known as Perl equality operators, equal, or not equal operators).

The Perl comparison operators are different for numeric and string comparison tests, as you can see in the following table:

Ruby FTP - A free Ruby script to throttle the FTP file upload speed

An interesting thing about developing software to work with an FTP server is that for some tests you need files to be uploaded to the FTP server very slowly. Usually you want software to run as fast as possible, but in my case I needed to be able to throttle the FTP upload speed to test portions of my code. (Specifically, I'm writing code to listen to Proftpd FTP server events, and I needed this to make sure all the STOR, DELE, RNFR, and RNTO events work as advertised (making sure the event notifications aren't sent until the event is complete.)

How to convert a DRM-protected song to an MP3

I've never bought any DRM protected (digital rights management) music, so although it's a well-known fact among techies, I didn't know until recently that you can burn DRM songs to a standard CD. The implication here is that once you've burned the DRM-protected song to CD, you can then rip it back as an MP3 file, which is the part that blows me away. Not much protection there, other than "security through obscurity".

Rule number one for software project managers

Here's my Rule #1 for Project Managers, as looked at from the perspective of a software developer:

Show active interest in your project, and in the people that work on the project.

Okay, I know that seems obvious -- and I'm a little fired up about this right now -- but I've been amazed to work with project managers in the last few years who seem to have more important things to do outside of work than they have to do at work, and by this I only mean during the Monday through Friday, 8-to-5 time frame.

Examples of the Unix mkdir command

Linux directory FAQ: How do I create (make) a directory on Linux or Unix?

The Unix/Linux mkdir command is used to create new Unix/Linux directories (sub-directories). Let's take a look at some mkdir command examples.

How to create one directory

This first example creates a new directory named tmp in your current directory:

mkdir tmp

This example assumes that you have the proper permissions to create a new sub-directory in your current working directory.

Syndicate content