I have been asked to present a day long seminar on Perl to a group of first and second year college students in the Software Engineering Technologist program. Since my current employer provides an XML from PDF conversion service, the instructor has also suggested I touch on XML in my seminar.

I can probably put together the Perl part of the course OK -- these folks have some experience with C++ so they'll pick up on the conditionals and loops right away. However, if you have suggestions for the five or six things(1) I should teach C++ programmers interested in learning Perl, as well as one or two cool things that I can show them in XML, let me know.

If they have some C++ you could probably just have a quick bit that covers the 3 basic data types $ @ % and then notes you almost always need ( ) { } and ; for syntax. Much of perls syntax is quite like C so you can probably skip the details and dive right in.

I would tell them they need to use strict, use warnings and that they declare vars with my and vars scope as expected.

They need to know how to execute a program so I would probably show them something like:

A traditional starter and shows a few things including the difference in perl between ' and " which generally bites everyone new to Perl.

A usesful widget for all programmers is find and replace, as is a full RE grep (especially on Win32 which is what they will probably be most familiar with). So you could show them a couple of simple one liners like:

This lets you give them something they can use in day to day coding, and a chance to mention REs and $_ default behaviour and slip in a mention that perl has all sorts of wierd $. type vars.

Then I would just dive straight into CPAN, as in physically go their download and compile a module or two.

Then show them how to use a few of the more important modules to make complex tasks into 10 line perl scripts. LWP::Simple and LWP::UserAgent let you demo extreme simplicity and then OO syntax. I will also let you get some XML from somewhere. You could perhaps show off a 6 line IO::Socket::INET function to introduce subs and show how simple socket programming can be in Perl. You could use this to get the XML as well. Then just do something with XML::Simple and do a bit of data munging on it. Perhaps if you have time you could connect to a database with DBI and store and retrieve some of the data you munged from your XML.

For debugging I would mention use diagnostics, $DEBUG && print "\$var1 is $var1 here\n" and Data::Dumper

As you go you get to explain more sytntax as needed and hopefully pique their interest. You can't teach them perl in a day but you can certainly whet their appetites and with the one liners at least give them a couple of useful tools.

I would skip GOLF and OBFU as they may be fun but don't actually explain why perl is useful.

The llama presented at normal teaching pace is about 16 hours of lecture.
This includes going over the exercises, and some standard joke material {grin}. This also includes any question answering time.

If we are careful to omit any "slight diversions", then it brings it down to about 12 hours of real lecture. Compressing the presentation slightly can bring that down to 10 hours. Omitting 2 hours of any of the material (usually the stuff at the end) brings it down to 8 hours.

I liked merlyn's suggestion of teaching from the Llama book. But I had a thought on how you might condense.

You mentioned that your target audience already have experience with C++. Take the philosophy of leading a horse (or budding Camels) to water, rather than trying to force him to drink. Rather than attempting to teach Perl in a day, teach those parts of Perl that are easy to see as advantageous strengths over, say, C++. If they're thirsty, they'll start with that kind of an introduction and run with it.

For example, while teaching out of Llama, specifically go over topics such as hashes, lists/arrays, regexps, go heavy on DWIM'ery, file operations, including specifying alternate input record separators, show a trick or two with split, a trick or two with map. Dynamically create code and eval it. Delve a little into references and data-structures. Use that to lead into doing a Schwartzian Transform with short-circuit fallthrough to demonstrate how to sort on multiple criteria... those are just a few thoughts.

I guess what I'm saying is that you probably can't teach Perl in a day, but you can teach why this group should invest the personal time required to learn it. Stress quick development time, rich syntax, extreme flexibility, etc. Even stress extensibility; the fact that Perl can incorporate C/C++ in its code, and the fact that C/C++ code can embed Perl. And by all means, show off CPAN. You have a good opportunity, in that you're talking to already reasonably coherent programmers. You will be most successful in turning a few of them into Perl programmers if you devote your time to showing what is in store for those who grab the torch and run with it.

If they know C++, they can probably think for themselves and learn another language on their own. 1-day isn't enough time for spoonfeeding.

Given they'll be able to pick up the syntax (hopefully they will). I'd show off features and let them learn some on their own. Hashes since they won't be used to them, auto-vivification, all the goodies on CPAN for really obscure stuff that would be incredibly hard in C, the cleanliness of Tk (if they know Java for example, they'll probably hate Swing), functional programming to attempt to blow their minds, etc. They'll be coming back for more if you do it right...

Also, I think you need to give at least one example of something that is incredibly hard to do in most languages, done in one line of Perl code. Open with it. Something like "who is winning the most democratic primaries by scraping CNN" or stock prices or something like that.

I won't be spoon-feeding these students -- I hope to be teaching a university level course in Perl, the Perl Community, and by inference, talking about the Open Source community. To get into this program they had to have adequate C, so I'm going to blaze over for and while loops so we can get on to the cool stuff.

I haven't used Tk and don't want to have to learn stuff for this seminar -- I'll stick with what I know.

Scraping CNN is a neat idea .. I may even see if I can grab an RSS feed from somewhere and show them how it's done in just a few lines of Perl.

Also, it may be obvious, but don't forget to plug PerlMonks as a great resource to go to once you have invested time to learn the language a bit. It has certaintly contributed to my love for the language. I think that's a huge advantage as this is a heavily-trafficked forum. Let them know the author of the llama and many other cool people post here and want to encourage learning and breaking the sound barrier (but this is not to say they shouldn't learn on their own too).

Well no one mentioned it yet, so I would suggest touching on CGI, since that will probably interest them from a practical standpoint. Show the params stuff, show them how to setup a form, and do emails from CGI, introduce them to Taint, doing file uploads, etc. That stuff is hard from c++, so they will probably appreciate it.

Given that these are C++ programmers, there are a lot
of things you don't have to spend much time on. You
can show them one while loop and they'll instantly know
how to write while loops. You can show them one
if/elsif/else series and they'll understand how that
works immediately too. Even suffix conditionals like
dosomething unless condition will probably
not be hard for them to pick up. (They may not
immediately start writing that way, but they'll be
able to read code that does that and follow it okay.)

You'll want to reserve a little more time for things
that are starkly different in Perl from C++. You want
to spend at least an hour on context, for example.
You want to show them Perl builtins that do different
things in scalar versus list context, and show them
different ways to create different kinds of context
(scalar versus list assignment, operators that expect
a scalar (such as + and .), list operators (such as
print), and so on). After you think they understand
all of that, you also want to show them how to make
their own subroutines behave differently according
to context. If you have time, you'll also want to
explain the advantages of this, which won't be
immediately apparent to some of them probably.

If you have time, it would be nice to spend an hour
or so on pattern matching.

You also dursn't fail to explain that
Perl doesn't have statements, only expressions, and
that *ALL* functions in Perl, if followed by a left
parenthesis, take their argument list inside the
parentheses and fit into the larger expression. You
specifically want to say that the print operator is
not an exception to this. Show them how turning on
warnings will give them "useless use of foo in void
context" messages when they forget about this.

Also, if you have time, talk about the difference
between and and or
versus && and ||. The
former are useful for linking whole expressions
together, but the latter are more useful for linking
simple conditions together within a larger expression.
When in doubt, parenthesize everything.

These students have been using C++ and .NET -- I plan to ask the instructor what assignments they've been doing recently, and see if I can take one or two of the tougher ones and doing it in a single line of Perl. I'm hoping for the 'dropped jaw' look. :)

I'm also going to talk about meta-subjects, such as this web site and the other Perl web sites that are available, as well as talk about the Perl community and YAPC::NA.

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other