Johnny B.: Frage zu WWW::Mechanize, bzw. HTML::Form

Hallo geehrtes Forum,

ich habe von WWW::Mechanize ein Formular als HTML::Form-Objekt übergeben bekommen. Der Dumper (> Danke nochmal, CPAN!) zeigt mir, daß in dem Objekt alle Fields und Values des Formulars stehen. Nur wie komme ich da denn jetzt ran?

Ich dachte es gäbe eine Möglichkeit etwa so:
my $hashref = $agent->current_form();
my %form    = %$hashref;

wo alle Fields und Values drin stehen, auf die ich dann so zugreifen kann:
my $vorname = $form{vorname};

Ich kann mit ja WWW::Mechanize auf jedes Value zugreifen mit
my $vorname = $agent->value( 'vorname' );

aber es erscheint mir extrem unelegant, dies für jedes Feld einzeln zu tun, wenn doch bereits alle Informationen ermittelt wurden und als fertiger Hash zur Verfügung stehen.

Kann mir da jemand auf die Sprünge helfen?
Muchas Gracias
JOhnnY B.

Hier der gekürzte Dump:

$VAR1 = 'enctype';
$VAR2 = 'multipart/form-data';
$VAR3 = 'action';
$VAR4 = bless( do{(my $o = 'http://www.adresse.de/index.php')}, 'URI::http' );
$VAR5 = 'method';
$VAR6 = 'POST';
$VAR7 = 'inputs';
$VAR8 = [
          bless( {
                   'value_name' => '*',
                   'value' => '0815',
                   'name' => 'id',
                   'id' => 'id',
                   'type' => 'text',
                   'size' => '28'
                 }, 'HTML::Form::TextInput' ),
          bless( {
                   'current' => 1,
                   'menu' => [
                               {
                                 'value' => '0',
                                 'name' => 'Herr'
                               },
                               {
                                 'seen' => 1,
                                 'value' => '1',
                                 'name' => 'Frau'
                               },
                               {
                                 'value' => '2',
                                 'name' => 'Firma'
                               }
                             ],
                   'name' => 'anrede',
                   'idx' => 1,
                   'type' => 'option'
                 }, 'HTML::Form::ListInput' ),
          bless( {
                   'value_name' => '',
                   'value' => 'Maxi',
                   'name' => 'vorname',
                   'id' => 'vorname',
                   'type' => 'text',
                   'size' => '28'
                 }, 'HTML::Form::TextInput' ),
          bless( {
                   'value_name' => '*',
                   'value' => 'Muster',
                   'name' => 'name',
                   'id' => 'name',
                   'type' => 'text',
                   'size' => '28'
                 }, 'HTML::Form::TextInput' ),
         ];
$VAR9 = 'attr';
$VAR10 = {
           'enctype' => 'multipart/form-data',
           'name' => 'be_formular',
           'id' => 'be_formular',
           'method' => 'post'
         };

  1. Hallo,

      
    my $formValues = {};  
      
    map($formValues->{$_} = $mech->current_form->param($_), $mech->current_form->param());  
      
    
    

    allerdings ist das eine sinnlose Copystrategie, die sowohl Speicher als auch Rechenzeit verschwendet.

    gruss

    1. Hallo asdf,

      map($formValues->{$_} = $mech->current_form->param($_), $mech->current_form->param());
      allerdings ist das eine sinnlose Copystrategie, die sowohl Speicher als auch Rechenzeit verschwendet.

      --- VIELEN DANK! Funktioniert super.

      Sinnlose Copystrategie?

      $person->{'name'} ist doch deutlich besser les- und verstehbar als $mech->current_form->param('name')

      Ich meine im Hinblick auf die Wartbar- und Übersichtlichkeit des Programms...

      Mille Grazie!
      JOhnnY B.