in reply to Most basic code to mess around with?
Hi,
Perl is my first language too.
Lot of great folks here have suggested good points, so nothing much to add however, you might find the following points useful.
The best code to mess with is the one you write yourself. Because you have written it, you know it, you can tweak it and see what happens.
I wrote something like this after dabbling with Perl initially:
#!/usr/bin/perl use warnings; use strict; print "Enter your name: "; chomp(my $name = <STDIN>); print "Your name is: $name\n";
And then I supplied my name. And it printed fine. Then I supplied it a number. And it still printed fine. The same thing failed when I tried in C, but Why? Because C makes you create a variable of type char or int or float. But not so with Perl. And off I went (re) reading about how Perl treats variables, how 4x4 is different from 4*4. Write your own code and mess with it. Once you are sure that it's running fine, purposely remove a colon, or a comma or something like that and see what error you get. That's the best way to learn when picking up Perl.
Try Strawberry Perl if you are on Windows. Its at - http://www.strawberryperl.com. It's easier to install modules in Strawberry Perl and there's a portable version available. So that you can extract it to a folder, do your stuff and copy the folder to a USB and try it out on any other Windows based computer. No need to install Perl :)
As mentioned by other folks here, Learning Perl is a great book and so is Beginning Perl (By Curtis Ovid Poe). You can get any (or both) and get started.
Most important: Don't do the mistake I did. I skipped the exercises in hope of saving time and learning quickly. It simply didn't work. I had to go back and do the exercises. It does make a difference.
|
|---|