作者onizi1224 (Onizi)
看板Perl
标题Re: [问题] 请教一个perl秀小数点最末位0的问题...
时间Fri Feb 1 15:19:57 2008
※ 引述《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: 192.192.58.2