package AM; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use NKF; use CGI::Lite; require Exporter; @ISA = qw(Exporter AutoLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw( ); $VERSION = '0.01'; # Preloaded methods go here. # Autoload methods go after =cut, and are processed by the autosplit program. sub new{ my $class = shift; my $self = {}; bless ($self, $class); $self; } sub setLang{ my $s = shift; my $japos = index($ENV{'HTTP_ACCEPT_LANGUAGE'}, 'ja'); my $enpos = index($ENV{'HTTP_ACCEPT_LANGUAGE'}, 'en'); if ($japos == -1){ $s->{lang} = "en"; }elsif ($enpos < $japos && $enpos != -1){ $s->{lang} = "en"; }else{ $s->{lang} = "ja"; } } sub parse{ my $s = shift; my $cgi = new CGI::Lite(); my %in = $cgi->parse_form_data; my ($key); foreach $key (keys %in) { $s->{$key} = nkf("-e -Lu", $in{$key}); } } sub setHtmlHead{ my ($s, $title) = @_; my ($charset, $jaeuc); if ($s->{lang} eq "ja"){ $charset = "euc-jp"; $jaeuc = "\n"; }else{ $charset = "en"; } $s->{htmlhead} = "Content-type: text/html\n\n $title \n"; $s->{htmlhead2} = " $title \n"; } 1; __END__ # Below is the stub of documentation for your module. You better edit it! =head1 NAME AM - Example of perl module by Akio Miyao =head1 SYNOPSIS use AM; $s = new AM; =head1 DESCRIPTION =head1 AUTHOR Akio Miyao, akio@miyao.info =head1 COPYRIGHT Copyright 2003, Akio Miyao =head1 SEE ALSO perl(1). =cut