[PerlChina] how test a string is number?

Qiang (James) Li shijialee at gmail.com
Tue Dec 13 21:12:42 PST 2005


我现在都是使用 Getopt::Long , 功能强大,也不复杂。具体看 perldoc Getopt::Long
拿里面的一个例子来讲,

use Getopt::Long;
my $data   = "file.dat";
my $length = 24;
my $float = 2.5;
my $verbose;
$result = GetOptions ("length=i" => \$length,    # 整数
                               "file=s"   => \$data,      # 字符串
                               "float=f"   => \$float,      # floating number
                               "verbose"  => \$verbose);  # flag

如果提供的参数不是要求的会提示的。

hm, any reason why you use english only here?  that makes other people
less helpful to you as not everyone good at english.

Qiang


On 12/13/05, 黄叶 <hylinux at gmail.com> wrote:
> HI, all
> I use the Getopt::Std gather the args from command line.
>
> example:
> #!/usr/bin/perl -w
> use strcit;
> use Getopt::Std;
> my %opts = ();
> getopt("d", \%opts);
>
> print $opts{"d"}
>
> Ok, Now I need a number value about the args named "d", but
> How i test the char is number?
>
> Thanks.


More information about the China-pm mailing list