Thread Finde den Fehler nicht in map-Konstrukt (Modification of a read-only value attempted) (8 answers)
Opened by Rolf_PlusW at 2010-11-03 16:49

Rolf_PlusW
 2010-11-03 16:49
#142430 #142430
User since
2006-12-13
22 Artikel
BenutzerIn
[default_avatar]
Hallo,
in meiner Anwendung tritt von Zeit zu Zeit ein Fehler auf, den ich nicht lokalisieren kann.
Die Source ist :
Code: (dl )
1
2
3
	my @pages = map { $_->{class} ne 'DT' ? 1 : 
( defined($_->{mid}) && grep ( /\w+/ , @{$_->{texts}} ) ? 1 : 0)
} @{$self->session->{caledit}->{pages}};

Die Variable {$self->session->{caledit}->{pages} sieht folgendermassen aus:
Code: (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
28
29
30
31
32
33
34
35
36
37
38
  'pages' => [
{
'mid' => '164',
'texts' => [
undef,
'FGFDBB'
],
'class' => 'DT'
},
{
'mid' => '159',
'texts' => [
undef,
'arfara'
],
'class' => 'DT'
},
{
'mid' => '154',
'texts' => [],
'class' => 'DT'
},
{
'mid' => '153',
'texts' => [
undef,
'',
'GAGRE',
'',
''
],
'class' => 'DT'
},
{
'mid' => undef,
'texts' => [],
'class' => 'DT'
..

(Zum Verständnis: Es wird geprüft, ob alle Elemente in caledit}{pages} die class 'DT" haben, mid gesetzt ist und in irgendeiner Zeile in @texts was steht ) . Ergebnis ist ein Array mit der gleichen Länge wie pages mit 0 oder 1 )


Die Fehlermeldung lautet dann:

Modification of a read-only value attempted at xyz.pm line 134.

Ich vermute mal er hat ein Problem mit $_ in dem geschachtelten map { grep} Konstrukt , wobei ich ja nicht grep {} @arr sondern grep ( patt, @arr) verwende, da tritt ja $_ eigentl. nicht in Erscheinung.
Wer hat ne Idee, was da falsch ist ?
Rolf

//MODEDIT GwenDragon: Titel erweitert
Last edited: 2010-11-03 17:43:10 +0100 (CET)

View full thread Finde den Fehler nicht in map-Konstrukt (Modification of a read-only value attempted)