Leser: 1
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl use strict; use warnings; sub readQuestion { my $FileName=shift(@_); my $CountLine=shift(@_); my $QuestionLine=''; open(QFILE,'<',$FileName) or die "Error opening \"$FileName\" ($!)\n"; $CountLine-- while($CountLine>0 && ($QuestionLine=<QFILE>)); close(QFILE); die "Not enought Lines in \"$FileName\"\n" if($CountLine>0); die "Line empty! \n" if($QuestionLine eq ''); chomp($QuestionLine); my $Separator=substr($QuestionLine,0,1,''); my @list=split(m/(?:\Q$Separator\E)+/,$QuestionLine); my $Category=shift(@list); my $Question=pop(@list); my $Answer=$list[0]; return ($Category,$Question,$Answer); } printf("C: %s \nQ: %s \nA: %s \n", readQuestion('test.txt',3)); exit(0);
pq+2007-09-22 12:27:02--wieso wird bei manchen beiträgen weder ein autor noch gast angezeigt? bug?
renee+2007-09-22 09:26:47--Kann es sein, dass es Leerzeilen in der Datei gibt??
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |