dep1078 has asked for the wisdom of the Perl Monks concerning the following question:
here is my save_content_binary method: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);
i know i'm meant to use the encode or decode methods, but not sure which one or when.sub save_content_binary { my $self = shift; my $filename = shift; open( my $fh, '>:utf8', $filename ) or $self->die( "Unable to crea +te $filename: $!" ); binmode $fh; decode("utf-8",$self->content); print {$fh} $self->content or $self->die( "Unable to write to $fil +ename: $!" ); close $fh or $self->die( "Unable to close $filename: $!" ); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Encoding a hash in perl before saving it as a CSV file
by zentara (Cardinal) on Aug 11, 2010 at 17:16 UTC | |
|
Re: Encoding a hash in perl before saving it as a CSV file
by graff (Chancellor) on Aug 12, 2010 at 02:26 UTC |