> I've been teaching myself Perl and C in preparation for a new job. I've been
> using Wrox's "Beginning Perl" and the Camel book for Perl, and K&R and the
> Deitel&Deitel "How to program " for C. Does anyone know of a Perl
> instruction book/web resource that has plenty of exercises (with example
> answers) like the Deitel book for C?

Yeah, it's called CPAN.  Basically, you look through the archive trying to
find some modules you think you'd find interesting, email the author and
see if they have things you can do.  It's quite easy, and you get to
contribute useful (?) code in the process, of course.

The equivenlent book for Java isn't exactly highly regarded amougst my fellow
students.  In fact, most of us have found it useless due to poor indexing and
content.  The exercises, however, have been grudgingly accepted as being good.

Why not take the general exercises from the Deitel book and try to implement
them in Perl.  In fact, most of them should work with a few minor changes,
the real challenge is getting the practice to know what's good Perl, and what
isn't.

E.g.

for ($line=0; $line<10; $line++) {
    printf ("Line: %d\n", $line);
}

might be Perl code (and very similar to the C version), but you are better to
write it as:

foreach $line (0 .. 9) {
    print "Line: $line\n";
}

Style issues are best checked by other people via code reviews, or studying
lots of good quality code.

> The main problem I've had learning Perl is trying to separate out the "need
> -to -know" stuff from the "very clever but you can get by without it" info,
> esp in the manpages and the Camel book. Also I find the exercises in the
> deitel book for C very useful for getting the syntax firmly learned.

You absolutely must know the difference between 'local', 'my' and 'our' so
you can use strictures and warnings (use strict; use warnings; ).  Any half
decent company/organisation will use these, so you must know.

In Perl, it can be important to unlearn all you know about optimising C
code.  Some C style constructs go against the flow in Perl, and subsequently
attract nasty runtimes.  Forget everything you know about bitwise operations,
they are slower than simply creating another variable.

> This is my first post so hope it's suitable,

Looks okay to me, some people here seem to beginners at communication in
general.  Unlike some mailinglists, you shouldn't be flamed for posting
semi-off topic stuff as long as it retains some element of Perl.

> University of Edinburgh
> Kings Buildings

Hmm... suppose you must live somewhere on this very campus thingy I write
from.  I guess we could find some time and skim over the Camel, pointing
out things that you will have to know, and what is useful to know.  You
have a 'Dr' before your name, so I guess you'll be able to cope with lots
of information at once ;-)

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to