#!/usr/bin/perl use WWW::Mechanize; use HTTP::Cookies; use Stream::Reader; $url="https://mymail.company.com"; my $username = "XXXXXXXXXX"; my $password = "xxxxxxxxxx"; my $mechanize = WWW::Mechanize->new(autocheck => 1); CHK_STRT: $mechanize->cookie_jar(HTTP::Cookies->new()); $mechanize->credentials($username,$password); $mechanize->get($url); $mechanize->get("https://mymail.company.com/exchange/User/Inbox/?Cmd=c +ontents&Page=1"); my $page = $mechanize->content(); $mechanize->get("https://mymail.company.com/exchange/User/Inbox/Sub_di +r_1/?Cmd=contents&Page=1"); my $Sub_1>get("https://mymail.company.com/exchange/User/Inbox/Sub_dir_ +2/?Cmd=contents&Page=1"); my $Sub_2 = $mechanize->content(); $mechanize->get("https://mymail.company.com/exchange/User/Inbox/sub_di +r_3/?Cmd=contents&Page=1"); my $Sub_3 = $mechanize->content(); $mechanize->get("https://mymail.company.com/exchange/User/Inbox/sub_di +r_4/?Cmd=contents&Page=1"); my $Sub_4 = $mechanize->content(); open(FH, ">school.txt") or die " Can't open school file\n"; binmode FH, ':utf8'; print FH $page; print FH $Sub_1; print FH $Sub_2; print FH $Sub_3; print FH $Sub_4; close(FH); my @substrings = ( 'icon-msg-unread.gif' ); my $handler; open( $handler,'<','school.txt' ) or die "can't Reopen the file\n"; my $stream = Stream::Reader->new( $handler ); my $result = $stream->readto(\@substrings, {Mode => 'E'}); #This mode +returns false $emails = 1; close $handler; open(WR, ">announce.txt"); if( $result ) { print WR "new\n"; $emails++; } elsif( $stream->{Error} ) { die "Fatal error during reading file!\n"; } else { print WR "old\n"; } close WR; unlink('C:/MC/school.txt'); system 'ftp -s:ftpc ftp.server > Log.log'; unlink 'Log.log'; sleep(60); goto CHK_STRT;
In reply to memory consumption by moked
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |