![]() |
|< 1 2 3 >| | ![]() |
26 Einträge, 3 Seiten |
1 2 3 4 5
1: my $hashref = sub { 2: return int(rand(1000)); 3: }; 4: print $hashref->(),"\n"; 5: print $hashref->(),"\n"; #ergibt dasselbe ergebnis wie beim ersten print()
1
2
3
4
5
my $ref = sub { return int rand 1000; };
print $ref->(), $/;
print $ref->(), $/;
646
777
1 2 3 4 5 6 7 8 9 10 11
sub funktion { { my $sth = ... , \%results } { my $sth = ... , \%results } }
$foto_handle = ... $foto_stmt ...;
$foto_sth = ... $foto_stmt ...;
$sth{foto} = ... $stmt{foto} ...;
Froschpopo+2007-12-28 10:58:00--Das verstehe ich nicht? Ich verstehe auch nicht, wofür du die vielen Variabeln brauchst. Und was du mit Parameter mitschleppen meinst ist mir auch nicht klar. Wenn ich mich recht erinnere Arbeitest du doch Modular, d.h. du kannst einen Modulweite Variabel an einer Stelle deklarieren.wenn ich eigene Subs mache, dann muss ich ja jadesmal die Parameter mitschleppen und diese dann erstmal wieder einbeziehen, was einiges an Schreibarbeit ist. Wenn ich diese ohnehin sehr kleinen Funktionen einfach dort einbette, wo ich sie brauche, dann kann ich die "Mutter"-variablen von funktion() benutzen, was das ganze erheblich vereinfacht.
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
sub profile { my ($dbh, $sql, $cgi, $cache) = @_; my $first_name = $cgi->param(...); my $last_name = $cgi->param(...); my $city_name = $cgi->param(...); my $tier_name = $cgi->param(...); my $phone_prv = $cgi->param(...); my $phone_mbi = $cgi->param(...); my $phone_biz = $cgi->param(...); # hier entstehen viele weiter Variablen, nicht alle aus $cgi, viele auch aus Unterprozessen, Abfragen und Rechenergebnisse. my @fields = (...); my %where = (...); my @tables = (...); my @order = (...); my ($stmt, @bind) = $sql->select(\@tables, \@fields, \%where, \@order); my $sth = $dbh->prepare($stmt); $sth->execute(@bind) or die $errors->output($DBI::errstr); my @fields2 = (...); my %where2 = (...); my @tables2 = (...); my @order2 = (...); my ($stmt2, @bind2) = $sql->select(\@tables2, \@fields2, \%where2, \@order2); my $sth2 = $dbh->prepare($stmt2); $sth2->execute(@bind2) or die $errors->output($DBI::errstr); my @fields3 = (...); my %where3 = (...); my @tables3 = (...); my @order3 = (...); my ($stmt3, @bind3) = $sql->select(\@tables3, \@fields3, \%where3, \@order3); my $sth3 = $dbh->prepare($stmt3); $sth3->execute(@bind3) or die $errors->output($DBI::errstr); }
1 2 3 4
my ($stmt2, @bind2) = $sql->select(\@tables2, \@fields2, \%where2, \@order2); 27: my $sth2 = $dbh->prepare($stmt2); 28: $sth2->execute(@bind2) 29: or die $errors->output($DBI::errstr);
![]() |
|< 1 2 3 >| | ![]() |
26 Einträge, 3 Seiten |