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

看板Perl作者 (Brian)時間17年前 (2008/02/01 10:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
大家好.. 我用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
文章代碼(AID): #17eeSNDf (Perl)
文章代碼(AID): #17eeSNDf (Perl)