Anonymous Scalars

in Perl Tips, Data Structures
by William Ward on March 27, 2003 3:38 pm

If you’ve done much Perl programming you’ve probably encountered the Anonymous Hash, Anonymous Array, and probably Anonymous Subroutines as well. Did you know there’s also an Anonymous Scalar? It’s one of those things that is not very useful most of the time, but is the perfect tool for some situations. Here are two situations where you can use them, however:

(more…)

Copying an Array, with Modifications

in Perl Tips, Data Structures
by William Ward on December 6, 2002 12:24 pm

It is often necessary to make changes to the elements of an array while copying it to a new variable. You might be making a regular expression substitution on each element, or only copying elements that match a certain pattern. In this column I’ll show you three different approaches to this problem, in the spirit of Perl’s motto, "There’s More Than One Way To Do It" (TMTOWTDI):

(more…)

Unique Arrays

in Perl Tips, Data Structures
by William Ward on July 21, 2002 4:37 pm

If you have an array that may contain the same value in several places, and you would like to sort the array and remove all duplicates, here’s one way to do it…

(more…)