- 論壇徽章:
- 0
|
本帖最后由 hojunix 于 2011-11-02 21:46 編輯
各位大大,悲劇啊,這作業(yè)太難了。。。。。做為一個(gè)非IT出生的人,太苦憋了。。。。。。跪求指教。。。
具體如下:
如果一個(gè)文件cookie_file內(nèi)容如下:(存在2個(gè)空行)
SessionID,029380,xyz.org.au,1385874000
ASPX_ANONYMOUS,CjnjrB,xyz.org,1356912000
SESSION_COLOUR,red,nosite.com,1341014400
SESSION_ACTIVE,FALSE,nosite.com,1341014400
username001,massimo.piccardi,hello.com.cn,2145830400
username012,john.smith,hello.com.cn,2145830400
username013,michael.zhang,hello.com.cn,2145830400
老師要求
1. 如何取出有效行數(shù)?也就是空行不計(jì)算在內(nèi)。
我用以下程序,無法自動(dòng)過濾掉空行。
open (FILE, $file) or print "Can't open $file: $!";
my @fileline = <FILE>;
close (FILE);
my $totalfile += ($#fileline + 1);
2. “-h(huán)” 搜索主機(jī)
如果鍵入:cookiemgr.pl cookies_file –h nosite.com (有效域名)
輸出:Found 2 cookies for host nosite.com
如果鍵入:cookiemgr.pl cookies_file –h fail.com.cn (<---此域名不存在)
Output: No cookies found for host fail.com.cn
3. “–d” 搜索日期
如果鍵入:cookiemgr.pl cookies_file –d 31/12/2012
輸出:Found 3 cookies expiring before or on 31/12/2012
4. “–s”
如果,該perl程序讀取本地cookie日志文件,那么
鍵入:cookiemgr.pl [本地cookie文件名] -s
輸出:你的ID,和全名
5. 以上功能不能同時(shí)或錯(cuò)誤的語法使用。
使用規(guī)則只能是以下4種:
1) ./cookiemgr.pl (文件名) -->輸出有效cookie數(shù);
2) ./cookiemgr.pl (文件名) -h (域名)-->輸出有效搜索結(jié)果,見上;
3) ./cookiemgr.pl (文件名) -d (截止日期)-->輸出有效搜索結(jié)果,見上;
4) ./cookiemgr.pl (文件名) -s -->輸出有效搜索結(jié)果,見上;
其他情況均輸出“Invalid syntax/options”。
萬分感謝。。。給個(gè)關(guān)鍵提示或關(guān)鍵的程序段就好,謝謝,謝謝!
補(bǔ)充,該程序運(yùn)行環(huán)境的時(shí)間默認(rèn)為UTC/GMT時(shí)間,也就是31/12/2012=1356912000,31/05/2010=1275264000。
第三個(gè)功能,輸入日期格式時(shí),必須用 XX/XX/XXXX |
|