print reverse <>; #可以將檔案反向列印出,like tac
查了reverse doc..
reverse LIST
In list context, returns a list value consisting of the elements of LIST in the opposite order. In scalar context, concatenates the elements of LIST and returns a string value with all characters in the opposite order.
print reverse <>; # line tac, last line first
undef $/; # for efficiency of <>
print scalar reverse <>; # character tac, last line tsrif
reverse完是將檔案一列一列回傳給陣列,並反轉
scalar是又將一個一個字元傳回給陣列,連內容都反轉....
$\是輸入分隔號
#reverse用法
#scalar用法
文章標籤
全站熱搜
