Thread HTML::Form ein <select> hinzufügen (19 answers)
Opened by bianca at 2023-07-21 12:04

bianca
 2023-07-22 10:01
#195159 #195159
User since
2009-09-13
6980 Artikel
BenutzerIn

user image
Etwas zum spielen.
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
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
54
55
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use HTML::Form;
local $Data::Dumper::Purity = 1;
local $Data::Dumper::Useqq = 1;
local $Data::Dumper::Deparse = 1;
local $Data::Dumper::Sortkeys = sub {
    my ($hash) = @_;
    return [(sort {lc $a cmp lc $b} keys %$hash)]; 
};
use 5.010;

my $html = <<HTMLHEREDOC
<html>
<head></head>
<body>
    <div>Ausgabe:</div>
    <form action="http://www.perl-community.de" method="post">
        <select name="fname">
            <option value="wert1">Anzeige1</option>
            <option value="wert2">Anzeige2</option>
            <option value="wert3">Anzeige3</option>
            <option value="wert4" selected>Anzeige4</option>
            <option value="wert5">Anzeige5</option>
        </select>
    </form>
</body>
HTMLHEREDOC
;

my @forms = HTML::Form->parse($html,'http://www.perl-community.de');
say Dumper(\@forms);

my %tmp = (
    name    => 'selname',
    menu    => [
        {
            name    => 'Zusanzeige1',
            value   => 'zuswert1'
        },
        {
            name    => 'Zusanzeige2',
            value   => 'zuswert2'
        },
        {
            name    => 'Zusanzeige3',
            value   => 'zuswert3'
        },
    ],
);

$forms[0]->push_input('option',{%tmp});
say Dumper(\@forms);

Warum scheitert mein ->push_input()?
10 print "Hallo"
20 goto 10

View full thread HTML::Form ein <select> hinzufügen