go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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. Bonus points if you have time to show them CPAN and several useful modules. Some examples of modules you might show them include WWW::Mechanize, HTML::Tree, Data::Dumper, Archive::Zip, Net::Server, and DateTime, but ideally you should pick modules that would be immediately useful for whatever it is that they do daily. ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print In reply to Things you cannot leave out of a one-day Perl course for C++ programmers
by jonadab
|
|