seekdir DIRHANDLE, POS |
設置當前位置DIRHANDLE到POS,POS的值返回telldir的前一個值。
seekdir()函數是類似:Unix的seekdir()係統調用。
0 - 失敗
1 - 成功
創建一個目錄testdir的 /tmp目錄內,並嘗試下麵的例子:
#!/usr/bin/perl -w #by www.gitbook.net opendir(DIR, "/tmp"); print("Position without read : ", telldir(DIR), "\n"); $dir = readdir(DIR); print("Position after one read : ", telldir(DIR), "\n"); print "$dir\n"; seekdir(DIR,0); $dir = readdir(DIR); print "$dir\n"; print("Position after second read : " , telldir(DIR), "\n"); closedir(DIR);
這將產生以下結果:
Position without read : 0
Position after one read : 1220443271
test.txt
test.txt
Position after second read : 1220443271