my ($confn,$pegfn,$pirfn,$pittmfn) = map { "$conf::backup_dir/$_-$tim.csv" } ("consum", "peg", "pir", "pittm"); $mech->follow_link(url_regex=>qr/sitestat\.com.*pir.*export_csv/i); $mech->save_content_binary($pirfn); #### sub save_content_binary { my $self = shift; my $filename = shift; open( my $fh, '>:utf8', $filename ) or $self->die( "Unable to create $filename: $!" ); binmode $fh; decode("utf-8",$self->content); print {$fh} $self->content or $self->die( "Unable to write to $filename: $!" ); close $fh or $self->die( "Unable to close $filename: $!" ); return; }