Re: [問題] 請教一個perl秀小數點最末位0的問題...

看板Perl作者 (Brian)時間17年前 (2008/02/05 10:35), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《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
文章代碼(AID): #17fykCql (Perl)
文章代碼(AID): #17fykCql (Perl)