Thread our $constant = 5; # und plötzlich undef (8 answers)
Opened by steffenw at 2007-07-31 17:20

steffenw
 2007-08-01 10:58
#97039 #97039
User since
2003-08-15
692 Artikel
BenutzerIn
[Homepage] [default_avatar]
Gut, ich gebe zu, im Beispiel war ein Fehler. Der Export funktionierte natürlich, das war nicht das Problem. Nachfolgend die korrigierte Version. Das Problem ist deswegen immer noch. Manchmal ist der Wert der Variable verfügbar, manchmal ist er undef.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
package MyConstants;

use strict;
use warnings;

use base qw(Exporter);
use Readonly qw(Readonly);

our @EXPORT = qw($constant);

Readonly our $constant => 5;

1;

Code: (dl )
1
2
3
4
5
6
7
8
9
#! perl

use strict;
use warnings;

use MyConstants;

# und manchmal ist $constant hier undef - warum?
print "content-type: text/plain\n\n$constant";
$SIG{USER} = sub {love 'Perl' or die};

View full thread our $constant = 5; # und plötzlich undef