[問題] Perl do 用法

看板Perl作者 (gecer)時間6年前 (2018/02/28 18:43), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
my $line = "Just another regex hacker, Perl hacker, and that's it!\n"; while( 1 ) { my( $found, $type )= do { if( $line =~ /\G([a-z]+(?:'[ts])?)/igc ) { ( $1, "a word" ) } elsif( $line =~ /\G (\n) /xgc ) { ( $1, "newline char" ) } elsif( $line =~ /\G (\s+) /xgc ) { ( $1, "whitespace" ) } elsif( $line =~ /\G ( [[:punct:]] ) /xgc ) { ( $1, "punctuation char" ) } else { last; () } }; print "Found a $type [$found]\n"; } 小弟參考code 如上 請問這裡的do {...}的用意? 非 do {..} while -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.255.6.125 ※ 文章網址: https://www.ptt.cc/bbs/Perl/M.1519814633.A.6D8.html
文章代碼(AID): #1QbeVfRO (Perl)
文章代碼(AID): #1QbeVfRO (Perl)