Caleb Cushing's Blog

Teaching Perl - Week 3 - Textual Data

So last week you should have covered variables, conditionals, flow control statements, calling functions, stdin/out/err, and using new perl features. This week we’re covering text processing, scalars, external libraries, and reinforcing what we learned last week. Text Processing is one of Perl’s specialty’s, mostly due to it’s powerful regular expression engine. First install LWP with cpan. cpanp -i Bundle::LWP will do it. #!/usr/bin/perl use strict; use warnings; use LWP::Simple; getprint(“"); Read more →

Teaching Perl - Week 3 - Prelude Commentary

So I think that Head First Programming: A Learner's Guide to Programming Using the Python Languageis a great guideline to teach any programming course, esp a 10 week course as it has 10 chapters. We’re one week behind. Arguably you could merge week 2 into week 1 and I may do just that in a rewrite of this series. In fact I’d suggest you do just that. But for now I’m going to continue on and we’ll see what people think once I reach the end. Read more →

Teaching Perl - Week 2 ( part2 )

This part2 was prompted by Chromatic’s post on state. I’d never heard of state before, and it’s documentation is poor. Let’s take a look at how state could affect our game. #!/usr/bin/env perl # guess a number game use strict; use warnings; use feature qw( say state switch ); say 'welcome'; # generate the winning number between 1 and 10 # see perlfaq4 for algorithm details my $winning_num = 1 + int( rand( (10-1)+1 ) ); until ( $winning_num == state $guess ) { say 'Guess a number between 1 and 10: '; $guess = readline(*STDIN); # check to see if we have a winner, or the guess is to high, or low. Read more →

Teaching Perl - Week 2

Week 0Week 1 (part 1)Week 1 (part 2)Guess the NumberSo our little game is exceptionally mediocre and not very fun. Head First Programming: A Learner's Guide to Programming Using the Python Languagesuggests we give the game player some help by telling them if the number is lower or Higher. use feature ‘say’; use strict; use warnings; say “welcome”; say “Guess the number: “; my $guess = readline(*STDIN); if ( $guess == 5 ) { Read more →

Teaching Perl - Week 1 - ( Part2 )

Week 0Week 1 (part 1)Padre - Perl IDENow let’s install Padre the Perl IDE to give the students a nice development environment. There are instructions on the website, however, cpanp -i Padre should get the trick done since it is on CPAN In the future Strawberry will ship with Padre but that future isn’t quite here. First ProgramOk so we want to make sure that we have Perl installed correctly and since you’re taking my advice I’m assuming that you’ve given your students access to 5. Read more →

Teaching Perl - Week 1 - ( Part1 )

Make sure you’ve read Part 0 first. As I said before Baker provides a Linux server for the perl class. However, none of the students have had a unix class. So I advise touching on it and giving them a link to these tutorials if they want to use it, and a helping hand. The book also talks about ActiveState but this isn’t the recommended way to do perl on windows anymore. Read more →

Teaching Perl - Part 0 - Preface

This is my 2 cents on how perl should be getting taught at my school. My school’s curriculum sucks in general across the board. But assuming I can’t change what classes are taught, when and what prerequisites this is how I would teach perl given the current computer science curriculum. Since people reading this are probably not familiar with the Fail that is Baker College (I would not choose Baker if I had to start again but credits don’t transfer easily, so it was easier to continue on with it). Read more →