作者unetin (Brian)
看板Perl
标题[问题] 请教一个perl秀小数点最末位0的问题...
时间Fri Feb 1 10:42:30 2008
大家好..
我用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呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 60.248.143.28