use strict; use diagnostics; use warnings; use WWW::Mechanize 'new'; my $mech = WWW::Mechanize->new(); $mech->get( 'http://tv.walla.co.il/?w=/2//353//2011-10-22/1' ); $mech = $mech->content( format => 'text' ); writeFile('del at will.txt',$mech); system('del at will.txt'); exit; sub writeFile { my $filepath = shift; my $nwntnt = join("",@_); $nwntnt = "\x{feff}".$nwntnt; #utf8 char starter no warnings; do { open(TXT, ">:utf8",$filepath); #open(txt, ">",$filepath); print TXT $nwntnt; close TXT; if($! and ($! ne 'No such file or directory') and ($! ne 'Bad file descriptor') ) { print 'Error writing to file: '.$!."\a\nPath: $filepath\nhit the enter to continue"; <>; } else{$! = '';} } while($!); }