User Tools

Site Tools


kurs:sparse_array.pl
use strict;


my @a;
$a[1] = 'eins';
$a[10] = 'zehn';
$a[100] = 'hundert';

my $i;
foreach (@a) {    
  printf "%s %s\n", $i, $_ if $_ ;  
  $i++;
  }

mit hash

use strict;

my %a;
$a{1} = 'eins';
$a{10} = 'zehn';
$a{100} = 'hundert';
$a{1000000} = 'million';
$a{1000000000} = 'milliarde';

foreach (sort keys %a) {
  printf "%s %s\n", $_, $a{$_};  
  
  }
kurs/sparse_array.pl.txt · Last modified: 2014/09/10 21:22 (external edit)