Re: [問題] 請教一個perl秀小數點最末位0的問題...
※ 引述《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
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章