CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
1st pearl problem

 



krmudvayne
New User

Feb 16, 2010, 7:27 PM

Post #1 of 8 (991 views)
1st pearl problem Can't Post

hi.. im a newbie in perl.. my instructor is not that good in teaching.. ive read alot but cant understand where to start or how..
here is my problem..
i have to write a perl program where:
1.i can add a name of student.(last name, first name, student number)
2.edit info about the student.
3.delete student name
4.and make use of hash..
5. use array in student number..


7stud
Enthusiast

Feb 16, 2010, 8:16 PM

Post #2 of 8 (985 views)
Re: [krmudvayne] 1st pearl problem [In reply to] Can't Post


Quote
i can add a name of student

To what? Your teacher may be poor, but you aren't very good at asking questions either.

As with any program that seems too complicated, break it down it to small pieces. Your steps do that. Try to write a program that does only the first step--that's it. Post your code if you have trouble with the first step, and ask a specific question about a problem you are having.

What book are you using for your class?


(This post was edited by 7stud on Feb 16, 2010, 8:16 PM)


krmudvayne
New User

Feb 16, 2010, 9:36 PM

Post #3 of 8 (980 views)
Re: [7stud] 1st pearl problem [In reply to] Can't Post

here is my code... i dont know what to do next..
sorry for my post..im not really good in english..

Add = 1;
$Delete = 2;
$Edit = 3;
$View = 4;

$option=();
{
print "Choose what to do <1-4>\n";
print "$Add. Add student name\n";
print "$Delete. Delete student name\n";
print "$Edit. Edit file\n";
print "$View. View student info\n";
}
$choose=<>;
if ($choose == 1){
print "insert First Name: ";
$FirstName =<>;
print "insert Last name: ";
$LastName=<>;
print "enter student number; ";
$Stdnumber=<>;
}
if ($choose == 2) {
print "insert First Name: ";
$FirstName =<>;
print "insert Last name: ";
$LastName=<>;
print "enter student number; ";
$Stdnumber=<>;
}
print "Choose again <1-4>\n";
print "$Add. Add a name\n";
print "$Delete. Delete name\n";
print "$Edit. Edit file\n";
print "$View. View Names\n";
$choose=<>;
if ($choose == 4) {
print "First Name: $FirstName\n";
print "Last Name : $LastName\n";
print "Student Number: $Stdnumber\n";
}

what i want is i can add name and when i select "view" i can see all the list of the name of the students ive inserted.. and when i choose edit.. i can edit their info..
and code their student number using arrays...

In Reply To


7stud
Enthusiast

Feb 17, 2010, 3:39 AM

Post #4 of 8 (973 views)
Re: [krmudvayne] 1st pearl problem [In reply to] Can't Post

Search google for 'code tags'. Read the first 10 matches and then come back and post what you've learned.


rovf
Veteran

Feb 17, 2010, 3:42 AM

Post #5 of 8 (971 views)
Re: [krmudvayne] 1st pearl problem [In reply to] Can't Post


In Reply To
here is my code... i dont know what to do next..
sorry for my post..im not really good in english..


Of course we can't write the program for you (otherwise you wouldn't learn anything), but:

First of all, I strongly suggest that you start every program you are writing with the lines


use strict;
use warnings FATAL => qw(all);


and, since you are a beginner, put

use diagnostics;

at the third line. I agree with you that your teacher really doesn't seem to be worth much if he didn't tell this to his students.

After having done this, re-run your program and see how far you get by yourself; then, please post again here.


krmudvayne
New User

Feb 17, 2010, 10:04 AM

Post #6 of 8 (963 views)
Re: [rovf] 1st pearl problem [In reply to] Can't Post

wow.. now im so confuse. after inserting it in the first part of the
code.. i run it.. it has so many error.. almost all area errors.. it seems that most of my codes are wrong.. now it gets really hard.. i dont know where to start///


7stud
Enthusiast

Feb 17, 2010, 9:26 PM

Post #7 of 8 (946 views)
Re: [krmudvayne] 1st pearl problem [In reply to] Can't Post

Before anyone can help you, you have to learn a couple of things:

1) You must follow directions.

2) You must answer the questions that people ask you.

At this point, you must answer the following questions:

a) What are code tags?
b) What book are you using?
b) What version of perl are you using?

Failure to follow directions and answer questions will cause people to stop replying to your questions. For instance, if you do not answer all three of those questions in your next post, I will stop responding to your questions.


(This post was edited by 7stud on Feb 17, 2010, 9:32 PM)


rovf
Veteran

Feb 18, 2010, 3:23 AM

Post #8 of 8 (933 views)
Re: [krmudvayne] 1st pearl problem [In reply to] Can't Post


In Reply To
wow.. now im so confuse. after inserting it in the first part of the
code.. i run it.. it has so many error.


This is exactly why I suggested doing it.


In Reply To
. almost all area errors.. it seems that most of my codes are wrong.. now it gets really hard.. i dont know where to start


From your posting, I guess that you are not only a beginner in Perl, but also that you have never written a computer program before. If your teacher has really not shown you how to start a program, I feel sympathy with you, because from my own work with beginners, I know how hard it is. Hence a few suggestions:

(1) From you programming style, you seem to write a program similar as writing a letter in a foreign language: We are not proficient in the foreign language, but we hope that as long our text is approximately right, the reader will understand us. Programming is different: Each piece of the program is either correct, or completely wrong. This means that every statement you write, must be completely understood by you, otherwise it doesn't make sense to proceed. For instance in your posting you wrote

Add = 1;

(which will have given raise to an error). Do you understand what it means? Can you explain it? If not, this is something you need to ask before proceeding.

(2) If you get many errors - and this will happen often even after you get more experience -, and you can't see the reason of the error, cut down your code as far as possible (by commenting out parts of it). Ideally, you are left with a small piece of code, maybe only 1-2 statements, which show the error. Now try to understand the error message. Maybe you see what is wrong. If you fail to understand it, post this small piece of code, together with the error message, and ask for help.

(3) Before writing actual code, write a sketch of the steps the program is supposed to do, in plain English. You can write these steps as Perl comments and leave them in the code, so they serve as documentation (and helps us seeing what you are going to do). Always be precise: Someone reading your writings, must fully understand what you want to accomplish.

HTH.

Ronald

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives