Computer Sciences Department logo

CS 368-1 (2011 Summer) — Day 2 Code Sample

The code from class is copied below.

To-Do List Code


use strict;
use warnings;

# Create empty list of to-do elements
my @todo;

# Add some items
$todo[0] = 'go grocery shopping';
push @todo, 'write slides for friday';
unshift @todo, 'talk to Miron';

# How long is the list?
print "List has " . scalar(@todo) . " tasks.\n";

# Print items
print join(', ', @todo);
print "\n";

print "First task: $todo[0]\n";