Perl: qw (quote words)

The tutor brings up a neat Perl utility that you often see used in discussions between programmers.

There are many articles on this site about arrays. To a newcomer, one that might be helpful is here.

The point of today’s post is that, in Perl, you can create an array as follows:

@furniture=(“table”,”couch”,”TV”,”desk”,”lamp”);

However, Perl programmers usually don’t mention it that way. They more likely write

@furniture=qw(table couch TV desk lamp);

According to Robert Pepper, qw means quote words, so it reads the words as if the quotations marks and commas were there.

qw saves a lot of effort if you’re creating arrays of strings:)

Source:

McGrath, Mike. Perl in easy steps. Southam: Computer Step, 2004.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Tagged with: , , , , ,

Leave a Reply