Perl list iteration

How to iterate over a list. You can use the Perl sort keyword to pre-sort your list if you wish.

#!/usr/local/bin/perl

use strict;
use warnings;

my @colours = sort qw( Blue Red Pink Orange Magenta Rose Salmon Black White Maroon Aqua);

foreach my $colour (@colours) {
        print ("$colour\n");
}

__END__
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: