CGI::ConvertParam - CGI::param()¥á¥½¥Ã¥É¤Ø¤Î´Á»ú¥³¡¼¥ÉÊÑ´¹¥Õ¥Ã¥¯¤ÎÄɲÃ
package CGI::ConvertParam::OngetUTF8; use base 'CGI::ConvertParam'; use Jcode; sub do_convert_on_get { my $self = shift; my $parameter_value = shift; return Jcode->new($parameter_value)->utf8; } 1; package client; use CGI; use CGI::ConvertParam::OngetUTF8; $query = CGI::ConvertParam::OngetUTF8->new(CGI->new); print $query->param('parameter_foo');
CGI::ConvertParam ¤Ï CGI.pm ¤Î param() ¥á¥½¥Ã¥É¤ò¥Ñ¥é¡¼¥á¡¼¥¿¤Î°ì³ç¤·¤¿Ê¸»ú¥³¡¼¥ÉÊÑ´¹¤ä¼èÆÀ»þ¤ÎÊÑ´¹¤â¤·¤¯¤ÏÀßÄê»þ¤ÎÊÑ´¹¤ò¹Ô¤¨¤ë¤è¤¦¤Ë³ÈÄ¥¤·¤Þ¤¹¡£Decorator¥Ñ¥¿¡¼¥ó¤Ë¤è¤Ã¤Æ³ÈÄ¥¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
package CGI::ConvertParam::EUC; use base 'CGI::ConvertParam'; use Jcode; sub initialize { my $self = shift; $self->convert_all_param; } sub do_convert_all { my $self = shift; my $strings = shift; return Jcode->new($strings)->euc; } 1; package main; use CGI; use CGI::ConvertParam::EUC; my $query = CGI::ConvertParam::EUC->new(CGI->new); print 'Name(EUC-JP):', $query->param('NAME');
package CGI::ConvertParam::OnsetShiftJIS; use base 'CGI::ConvertParam'; use Jcode; sub do_convert_on_set { my $self = shift; my $strings = shift; return Jcode->new($strings)->sjis; } 1; package main; use CGI; use CGI::ConvertParam::OnsetShiftJIS; my $query = CGI::ConvertParam::OnsetShiftJIS->new(CGI->new); $query->param(NAME => $value); print 'Name(Shift-JIS):', $query->param('NAME');
package CGI::ConvertParam::OngetUTF8; use base 'CGI::ConvertParam'; use Jcode; sub do_convert_on_get { my $self = shift; my $strings = shift; return Jcode->new($strings)->utf8; } 1; package main; use CGI; use CGI::ConvertParam::OngetUTF8; my $query = CGI::ConvertParam::OngetUTF8->new(CGI->new); $query->param(NAME => $value); print 'Name(UTF-8):', $query->param('NAME');
The new() method is the constructor for a CGI::ConvertParam and sub-class. CGI_BOJECT is the reference of the CGI instance. It return a specialized CGI instance.
new() ¥á¥½¥Ã¥É¤Ï CGI::ConvertParam ¤È¤½¤Î¥µ¥Ö¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿¤Ç¤¹¡£CGI_OBJECT ¤Ë CGI¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÅϤ¹¤È¡¢³ÈÄ¥¤·¤¿ CGI.pm ¸ß´¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£
convert_all_param() ¥á¥½¥Ã¥É¤ÏÁ´¤Æ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÊÑ´¹½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£
CGI::ConvertParam ¤Ï¥µ¥Ö¥¯¥é¥¹¤òºîÀ®¤·¥á¥½¥Ã¥É¤ò¾å½ñ¤¡Ê¥ª¡¼¥Ð¡¼¥é¥¤¥É¡Ë¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¼ÂÁõ¤ò¹Ô¤¤¤Þ¤¹¡£¾å½ñ¤¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¥á¥½¥Ã¥É¤Ï°Ê²¼¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤:
¤³¤Î¥á¥½¥Ã¥É¤Ï new() ¥³¥ó¥¹¥È¥é¥¯¥¿¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£initialize()¥á¥½¥Ã¥É¤ò¾å½ñ¤¤¹¤ë¤³¤È¤Ç¥Ñ¥é¥á¡¼¥¿¤ÎÄɲää¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤Ï param('name' => $value) ¤Ê¤É¡¢param() ¥á¥½¥Ã¥É¤ÇÃͤòÀßÄꤹ¤ëÁ°¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤Ï param('name') ¤Ê¤É¡¢param()¥á¥½¥Ã¥É¤ÇÃͤò»²¾È¤¹¤ë¤È¤¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤Ï convert_all_param()¥á¥½¥Ã¥É¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤Ï³ÈÄ¥¤¹¤ëÁ°¤ÎCGI¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£
CGI
OYAMA Hiroyuki <oyama@crayfish.co.jp> http://perl.infoware.ne.jp/
Copyright(c) 2000, OYAMA Hiroyuki. Japan. All rights reserved.
CGI::ConvertParam class may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'CGI::param()¥á¥½¥Ã¥É¤Ø¤Î´Á»ú¥³¡¼¥ÉÊÑ´¹¥Õ¥Ã¥¯¤ÎÄɲÃ'. Assuming CP1252
To install CGI::ConvertParam, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::ConvertParam
CPAN shell
perl -MCPAN -e shell install CGI::ConvertParam
For more information on module installation, please visit the detailed CPAN module installation guide.