Thread HTML::Template & Referenzen / Hash (3 answers)
Opened by Gast at 2007-10-30 10:51

Gast Gast
 2007-10-30 10:51
#101553 #101553
Hallo Perl-profis,

steh gerade vor einem kleinen Problem. Vieleicht hat ja jemand kurz Zeit, sich das mal anzusehen.
Es geht um folgendes:

Ich habe hier eine Subfunktion namens get_switchip(). Sie gibt mir ein array mit IPs zurueck. Dann hab ich HTML::Template beauftragt, bitte alle IPs darzustellen. Ich wollt's so machen:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
  my @switch_ips = &get_switchip();


  my @switch_ips_out;

  foreach my $switch ( @switch_ips ) {
    my %switch_ips = (IP => $switch->[0]); # problem! ich brauch 0 .. $#switch_ips ! So bekomme ich nur eine IP .. irgendwie
    push(@switch_ips_out, \%switch_ips);
  }


hab das Problem mal markiert. Ich bekomme als Output im HTML nur EINE IP. Brauch aber die Liste. Im HTML sieht's so aus:

Code: (dl )
1
2
3
      <TMPL_LOOP NAME="SWITCHIPS">
<option><TMPL_VAR NAME="IP"></option>
</TMPL_LOOP>


Wie kann ich es schaffen, HTML::Tempalte zu ueberreden, alle IPs zu zeigen? Ich schaetze ich brauch nichtmal einen hash, ich will ja keine Tabelle darstellen oder sowas. Das Array ist definitiv vollstaendig, weil wenn ich $switch->[1] schreibe bekomm ich die zweite IP, aber nicht *alle*


Schoenen Gruß,

rperl

View full thread HTML::Template & Referenzen / Hash