9 Einträge, 1 Seite |
[Mon May 22 22:52:01 2006] 1.cgi: Variable "$template" will not stay shared at /var/www/perl/1.cgi line 40.
[Mon May 22 22:52:01 2006] 1.cgi: Subroutine build_selectbox redefined at /var/www/perl/1.cgi line 13.
[Mon May 22 22:52:01 2006] null: Use of uninitialized value in numeric eq (==) at /var/www/perl/1.cgi line 27.
[Mon May 22 22:52:01 2006] null: Use of uninitialized value in array element at /var/www/perl/1.cgi line 32.
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
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
use strict;
my $template = HTML::Template->new(filename => '1.tmpl');
my $cgi = CGI->new();
sub build_selectbox
{
my ($loop_name, $selected_var, @a_selectbox_values) = @_;
my ($i, $selected, @a_selectbox_loop);
if (!defined($selected_var))
{
$selected_var = 1;
}
for(@a_selectbox_values)
{
$selected=0;
if ($i == $selected_var)
{
$selected=1;
}
push(@a_selectbox_loop,{
selectbox_label => $a_selectbox_values[$i],
selectbox_value => $i,
selectbox_selected => $selected
});
$i++;
}
$template->param({$loop_name => \@a_selectbox_loop});
}
my @a_array = ('---','Berlin','Wien','Bern');
&build_selectbox('loop_kursort', 2, @a_array);
print $template->output;
1
2
3
4
5
<select name="kursort">
<!-- TMPL_LOOP NAME="loop_kursort">
<option value="<!-- TMPL_VAR NAME="selectbox_value"-->"<!-- TMPL_IF NAME="selectbox_selected"--> selected<!-- /TMPL_IF-->> <!-- TMPL_VAR NAME="selectbox_label"--> </option>
<!-- /TMPL_LOOP-->
</select>
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1 #!/usr/bin/perl -w
2
3 use CGI;
4 use CGI::Carp qw(fatalsToBrowser);
5 use HTML::Template;
6 use strict;
7
8 my $template = HTML::Template->new(filename => '1.tmpl');
9 my $cgi = CGI->new();
10
11
12 sub build_selectbox
13 {
14 my ($loop_name, $selected_var, @a_selectbox_values) = @_;
15
16 my ($i, $selected, @a_selectbox_loop);
17
18 if (!defined($selected_var))
19 {
20 $selected_var = 1;
21 }
22
23 for(@a_selectbox_values)
24 {
25 $selected=0;
26
27 if ($i == $selected_var)
28 {
29 $selected=1;
30 }
31
32 push(@a_selectbox_loop,{
33 selectbox_label => $a_selectbox_values[$i],
34 selectbox_value => $i,
35 selectbox_selected => $selected
36 });
37 $i++;
38 }
39
40 $template->param({$loop_name => \@a_selectbox_loop});
41 }
42
43
44 my @a_array = ('---','Berlin','Wien','Bern');
45 &build_selectbox('loop_kursort', 2, @a_array);
46
47 #<select name="kursort">
48 # <!-- TMPL_LOOP NAME="loop_kursort">
49 # <option value="<!-- TMPL_VAR NAME="selectbox_value"-->"<!-- TMPL_IF NAME="selectbox_selected"--> selected<!-- /TMPL_IF-->> <!-- TMPL_VAR NAME="selectbox_label"--> </option>
50 #<!-- /TMPL_LOOP-->
51 #</select>
52
53 print $template->output;
Quote1.cgi: Subroutine build_selectbox redefined at /var/www/perl/1.cgi line 13.
Quotenull: Use of uninitialized value in numeric eq (==) at /var/www/perl/1.cgi line 27.
my ( $i, $selected, @a_selectbox_loop );
QuoteUse of uninitialized value in array element at /var/www/perl/1.cgi line 32.
selectbox_label => $a_selectbox_values[$i],
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 -w
use strict;
use Data::Dumper;
#use CGI;
#use CGI::Carp qw(fatalsToBrowser);
#use HTML::Template;
#my $template = HTML::Template->new( filename => '1.tmpl' );
#my $cgi = CGI->new();
sub build_selectbox {
my ($l_name, $selected, @options) = @_;
return { $l_name => [ map {
{
selectbox_label => $options[$_],
selectbox_value => $_,
selectbox_selected => $selected == $_ ? 1 : 0,
}
} (0 .. $#options) ] };
}
my @a_array = ( '---', 'Berlin', 'Wien', 'Bern' );
die Dumper &build_selectbox( 'loop_kursort', 2, @a_array );
# $template->param( build_selectbox( 'loop_kursort', 2, @a_array ) );
# print $template->output;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$VAR1 = {
'loop_kursort' => [
{
'selectbox_label' => '---',
'selectbox_selected' => 0,
'selectbox_value' => 0
},
{
'selectbox_label' => 'Berlin',
'selectbox_selected' => 0,
'selectbox_value' => 1
},
{
'selectbox_label' => 'Wien',
'selectbox_selected' => 1,
'selectbox_value' => 2
},
{
'selectbox_label' => 'Bern',
'selectbox_selected' => 0,
'selectbox_value' => 3
}
]
};
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 -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
use strict;
my $template = HTML::Template->new(filename => '1.tmpl');
my $cgi = CGI->new();
sub build_selectbox {
my ($l_name, $selected, @options) = @_;
return { $l_name => [ map {
{
selectbox_label => $options[$_],
selectbox_value => $_,
selectbox_selected => $selected == $_ ? 1 : 0,
}
} (0 .. $#options) ] };
}
my @a_array = ('---','Berlin','Wien','Bern');
$template->param( build_selectbox( 'loop_kursort', 3, @a_array ) );
print "Content-Type: text/html; charset=utf-8\n\n", $template->output;
print "Content-Type: text/html; charset=utf-8\n\n", $template->output;
Quotekann man das eigentlich auch kürzer schreiben (perl-like), wenn nicht defined dann initalisiere ?
$i = 0 unless ( defined($i) );
$i = defined($i) ? $i : 0;
my $i = 0;
9 Einträge, 1 Seite |