Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]8003[/thread]

verknuepftes Pattern matching: Pattern nach UND NICHT matchen (Seite 2)



<< |< 1 2 >| >> 17 Einträge, 2 Seiten
GwenDragon
 2006-05-21 20:42
#66397 #66397
User since
2005-01-17
14848 Artikel
Admin1
[Homepage]
user image
Code: (dl )
 if $_ (m/$lines[$i]->[0]|$lines[$i]->[5]|$lines[$i]->[8]/ && $_ !~ m/"(F)"/)
:rock:
Code: (dl )
 if ($_ =~ m/$lines[$i]->[0]|$lines[$i]->[5]|$lines[$i]->[8]/ && $_ !~ m/"(F)"/)

Das ieht richtiger aus.

Aber wie pq schon sagte: def tutsnicht()!
nikster77
 2006-05-21 20:45
#66398 #66398
User since
2006-02-08
26 Artikel
BenutzerIn
[default_avatar]
Hi PQ.
"Tut's nicht" bedeutet, das es "alles scheint OK zu sein" schreiben muesste.

Stattdessen gibt mir perl -Mdiagnostics meinscript folgendes:

Quote
Execution of meinscript.pl aborted due to compilation errors (#1)
(F) Probably means you had a syntax error. Common reasons include:

A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.

Often there will be another error message associated with the syntax
error giving more information. (Sometimes it helps to turn on -w.)
The error message itself often tells you where it was in the line when
it decided to give up. Sometimes the actual error is several tokens
before this, because Perl is good at understanding random input.
Occasionally the line number may be misleading, and once in a blue moon
the only way to figure out what's triggering the error is to call
perl -c repeatedly, chopping away half the program each time to see
if the error went away. Sort of the cybernetic version of S<20
questions>.

Uncaught exception from user code:
syntax error at meinscript.pl line 41, near "if $_ "
syntax error at meinscript.pl line 46, near "}"
Execution of meinscript.pl aborted due to compilation errors.
at meinscript.pl line 46


P.S:
Ich benutze jetzt use strict; und use warnings;
Ronnie
 2006-05-21 20:48
#66399 #66399
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
[quote=nikster77,21.05.2006, 18:33]
Code: (dl )
if $_ (m/$lines[$i]->[0]|$lines[$i]->[5]|$lines[$i]->[8]/ && $_ !~ m/"(F)"/) {
[/quote]
hör auf die Drachin!
nikster77
 2006-05-21 20:55
#66400 #66400
User since
2006-02-08
26 Artikel
BenutzerIn
[default_avatar]
Ah... OK Danke :)
Die Postings haben sich wohl ueberschnitten.
Jetzt bekomme ich nur noch:
Quote
Use of uninitialized value in pattern match (m//) at meinscript.pl line 42 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.


aber das liegt wohl daran das er die Variablen wahrscheinlich nicht richtig in die Subroutine uebernommen hat...
Ich hoffe das finde ich selbst raus.
GwenDragon
 2006-05-21 21:05
#66401 #66401
User since
2005-01-17
14848 Artikel
Admin1
[Homepage]
user image
Na, irgendwas ist vielleicht eine Leerzeile, eines der ominösen $lines[$i]->[...] oder ...
Dann warnt es eben.

Deswegen solltest du mit defined und length auch prüfen, ob lines[$i]->[xyz] auch was sinnvolles in sich trägt.

Oder du läßt use warnings und use strict weg, je nach dem wie sorgfältig oder schlampig du arbeiten willst.

Aber das ist dann keine saubere Programmierung mehr und selten zu empfehlen.

Perl vergib ihnen, denn sie wissen nicht was sie tun!
The Book of Wall 5,13

;)\n\n

<!--EDIT|GwenDragon|1148231487-->
renee
 2006-05-21 21:23
#66402 #66402
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Wobei man sehr wahrscheinlich die () noch escapen muss:
Code: (dl )
 if ($_ =~ m/$lines[$i]->[0]|$lines[$i]->[5]|$lines[$i]->[8]/ && $_ !~ m/"\(F\)"/)
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/
GwenDragon
 2006-05-21 21:41
#66403 #66403
User since
2005-01-17
14848 Artikel
Admin1
[Homepage]
user image
Hast du eine Glaskugel oder bist du gar Präcog? Toll.
Anscheinend bin ich zu "olsch", das zu sehen, was Poster so denken und wissen wollen ;)
<< |< 1 2 >| >> 17 Einträge, 2 Seiten



View all threads created 2006-05-21 19:28.