Schrift
[thread]10337[/thread]

Unmatched [ in regex (Seite 2)

Leser: 1


<< |< 1 2 >| >> 15 Einträge, 2 Seiten
topeg
 2007-09-22 14:07
#99854 #99854
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Das funktioniert bei mir ohne Probleme:
Code (perl): (dl )
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 14:27
#99855 #99855
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
wieso wird bei manchen beiträgen weder ein autor noch gast angezeigt? bug?
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
renee
 2007-09-22 14:51
#99857 #99857
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
pq+2007-09-22 12:27:02--
wieso wird bei manchen beiträgen weder ein autor noch gast angezeigt? bug?


wo??

edit: hab's grad gesehen... keine ahnung...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Gast Gast
 2007-09-22 17:29
#99861 #99861
renee+2007-09-22 09:26:47--
Kann es sein, dass es Leerzeilen in der Datei gibt??

hab gerade nachgeschaut es gibt keine Leerzeilen
topeg
 2007-09-22 20:01
#99866 #99866
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Wie sieht dein Code denn jetzt aus? Was hast du geändert?
<< |< 1 2 >| >> 15 Einträge, 2 Seiten



View all threads created 2007-09-07 01:09.