\D 是 [^0-9] ,范围太大了, 基本没怎么用过
2010/1/7 flw <[email protected]> > 为什么不写成 > > if ( $page =~ /\D/ ){ > die "not int\n"; > } > > 可读性和效率应该都会好一点点。 > > 顺便说一句,其实有好些模块有更准确的实现: > > use Scalar::Util qw(looks_like_number); > use Scalar::Util::Numeric qw(isnum isint isfloat); > use Data::Types qw(:all); > > 2010/1/6 Fayland Lam <[email protected]> > >> unless ( $page =~ /^\d+$/) { >> >> die "$page is not interger\n"; >> >> } >> >> On 2010-1-6 9:22, joewu wrote: >> >> 代码如下: >> if($page>0&&$page<=$count) >> { >> ..... >> } >> 这里的$page如何确保它为整型呢?能不能不用integer模块啊? >> >> >> -- >> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >> >> >> >> -- >> Fayland Lam // http://www.fayland.org/ >> >> >> -- >> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >> 要取消订阅此网上论坛,请发送电子邮件至 >> [email protected]<perlchina%[email protected]> >> 。 >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >> >> > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 > [email protected]<perlchina%[email protected]> > 。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > > -- Yours Sincerely Zeng Hong--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
