我有道perl题请高手们教下 我是学生刚学

来源:百度知道 编辑:UC知道 时间:2024/05/25 18:19:30
the file like this "student name;student number; email address;"you have to put ";" after all things to make sure you can break them up again. you will get the name, student number and email address and put all three in three different variables. Then you will print it to the file. This is the code to print to the file. print File $stu_name.";".$stu_number.";".$stu_email.";\n"; you have your three variables and then a '.' after each thing. The '.' means the same thing as '+', so you are adding everything to one line. To print it nicely on the screen the code is: format = @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< $stu_name[0],$stu_number[1],$stu_email[2] # these are all variables you want to print.

i can't understand your question clearly? maybe :

print "please input the stu_name,end with ctrl+d \n";
@stu_name=<STDIN>;
print "please input the stu_number,end with ctrl+d \n";
@stu_number=<STDIN>;
print "please input the stu_email,end with ctrl+d \n";
@stu_email=<STDIN>;
foreach (0 .. $#stu_name)
{print "the $stu_name[$_] number is $stu_number[$_] ,e-mail is $stu_email[$_] ;}

there is some easy way to do this , use hash? make a link between each elements.