作者unetin (Brian)
看板Perl
标题Re: [问题] 请教一个perl秀小数点最末位0的问题...
时间Tue Feb 5 10:35:55 2008
※ 引述《onizi1224 (Onizi)》之铭言:
: ※ 引述《unetin (Brian)》之铭言:
: : 大家好..
: : 我用perl script在写个UI,要将某机器上的全部网卡都秀出来,包含切好的vlan device:
: : foreach my $eth ( -1..7,@vlandev )
: : {
: : $eth=~s/eth//;
: : my $status=( $eth eq $ethnum ) ? ('selected'):('');
: : my $ethvalue=( $eth eq "-1" ) ? ('-1'):('eth'.$eth);
: : my $portvalue=( $eth eq "-1" ) ? ('None') : ('PORT '.++$eth);
: : print qq (<option $status value="$ethvalue">$portvalue</option>);
: : }
: : @vlandev的内容为eth1.2 eth1.3 eth1.4 eth1.10 eth1.11
: : 我print出来却变成PORT1...PORT8,PORT2.2 PORT2.3 PORT2.4 PORT2.1 PORT2.11
: : 因为".++$eth"导致我的最後一个0不见了...
: : 请问该如何print PORT2.10而不是 PORT2.1呢?
: 白痴解答 写死
: $PORT.'0'
: XD
...........这解答没办法用...>"<
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.105.179.15