separator

Take a quiz or make one of your own

Perl's Quote Words Feature

You Don't Always Have To Use Quotes

Perl has a handy feature called 'quote words' which allows you under certain circumstances to avoid the use of quotes altogether.

Example I

my @peppers = qw(green red yellow black cayenne);

an alternative to the coding :

my @peppers = ('green','red','yellow','black','cayenne');

What's nice about using quote words is that sometimes it's easier to read text that's coded this way.

Example II

foreach my $pepper(qw(green red yellow black cayenne))
   {print "$pepper Pepper\n"}

an alternative to the coding :

foreach my $pepper('green','red','yellow','black','cayenne')
   {print "$pepper Pepper\n"}

Related Projects by Face 2 Interface/What is a CGI-BIN?/Use Strict!/Quoting Text in Perl/Choose Your Quote Character/Perl's Quote Words Feature

separator

© www.thecgibin.com