It sounds like the first thing you need to do is figure out just what the Perl idioms you're referring to are! For me, the following compose a partial list:
- EVERYTHING HAS USE STRICT AND USE WARNINGS/-w ... Don't go any further unless this is in your curriculum. I know that's being an ass, but I feel that strongly about it.
- $_ and @_ and how they're the defaults. (This is a big one!)
- statement modifiers foo($_) while (1 .. 10);
- grep and map - Spend a lot of time here!
- range operator as a boolean short-circuit
- regexes as pretty much anything (booleans, shortcircuits in ranges, etc)
- Using regexes to parse
- Using substr to parse
- References. Use the pointer concept to start, but break away from it ASAP, as references are NOT pointers.
Basically, make sure they understand TMTOWDI and that their C-Perl is no better or worse than someone else's Java-Perl or my Perl-Perl. :-)
As for getting them to think in Perl, force them into text-manipulation. That's where Perl started and that's where it shines. Ask them to find all the occurrences of a regex-match in a file. Have them do it in their favorite language, then in Perl. Show them 3-4 different ways in Perl, starting with the most C-like, then moving slowly to Perlisms. Try and remember how you discovered things like:
LINE:
while (<INFILE>) {
next LINE while /Foo/ .. /Bar/;
chomp;
# Do stuff here.
}
How you discovered the idioms is how you want them to discover them ... through iterative runs of the same solution, but written more and more Perlish.
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.