Farid Hajji: Perl - Einführung, Anwendungen, Referenz
2., aktualisierte und erweiterte Auflage
Addison-Wesley Longman, ISBN 3-8273-1535-2
cgi-s-pathinfo.pl
#!/usr/local/bin/perl -w
# cgi-s-pathinfo.pl -- Zustandserhaltung mit PATH_INFO.
use strict;
use CGI qw(:standard);
my $state = retrieve_state();
my $nextstate = compute_next_state($state);
my $saveaction = save_state($nextstate, "Click me for next state");
# Tue etwas abhaengig von $state:
print header,
start_html('State with PATH_INFO'),
"Current state: ", $state, p,
$saveaction,
end_html;
use constant INITSTATE => 1;
sub retrieve_state {
my $state = $ENV{'PATH_INFO'} || INITSTATE;
$state =~ s,^/,,;
return $state;
}
sub compute_next_state {
my $current_state = shift;
return $current_state + 1;
}
sub save_state {
my $newstate = shift;
my $info = shift;
my $send_me_back = a({-href => url() . "/$newstate"}, $info);
return $send_me_back;
}
[Prev] [Up] [Relevant Chapter] [Next]
[Alte Quelle]
| Last modified: $Date: 2006/05/18 12:55:53 $ FH. Search :: Sitemap :: Disclaimer :: Copyright :: Privacy |
|