Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
Perl Programming

Tutorial: Quilts - Using variables

 

We can use variables to reduce the amount of code we write.

CommandMeaning
Quilt.b
Quilt.c
Quilt.b.turn()
Quilt.b.sew(Quilt.c)

1. Repeating a column


Big

Change the program so that it makes a 3 by 2 grid.



2. Chevrons


Big

Create a tilted square.

Variable ch is a chevron. Turn it twice and sew it on.

You can use turn(2) for turn().turn()



3. Four tilted squares


Big

Define ts as the tilted square from the previous question. Then build up more.





4. c square


Big

We can do something similar with c.



5. Stripes


Big

Bigger stripes.