Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: Optional Arguments..?by davido (Cardinal) |
on Jun 03, 2012 at 07:18 UTC ( [id://974090]=note: print w/replies, xml ) | Need Help?? |
Google is great, but I'm surprised your professor didn't mention the Perl documentation. It's included free of charge with every Perl distribution, and also at http://perldoc.perl.org. You can read about defined on your own terminal by typing "perldoc -f defined".
No. Well... your use of defined is reasonable, but besides that, NO. It doesn't compile. Why would you post code that doesn't compile except to possibly ask why it doesn't? You can check yourself, at which point you can begin working through the error messages. For example, "Not enough arguments for keys at mytest.pl line 27, near "keys =~"" Your line numbers will probably be different, but that error message will still be there, unless the code you posted isn't what's in your editor. There's no need for me to enumerate the error messages you're getting; Perl will do it for you when you type perl -c mytest.pl, where "mytest.pl" is the name of your script. Once you resolve the issues that perl -c tells you about, you'll run into other problems as well, such as your strange for loop around line 31. It seems to set a topical variable, but the list of items it iterates over is empty, and the print statement on the next line tries to print $_, which isn't going to contain anything meaningful. Really, there are enough problems you probably should sit down with your instructor for a half hour and go over them together. If you don't have it already, get yourself a copy of Learning Perl, and start reading. It will begin to flow before you know it. And remember this slightly gentler version of a famous quote within the Perl community: "You can't just make stuff up and expect the computer to know what you mean." Programming rewards attention to detail. Dave
In Section
Seekers of Perl Wisdom
|
|