use Exporter;
-our $VERSION = '1.0.13';
+our $VERSION = '1.0.14';
our @ISA = qw(Exporter);
our @EXPORT = ();
our @EXPORT_OK = (
- 'read_data_file', 'write_data_file',
+ 'read_data_file', 'write_data_file', 'write_postdata_file',
'read_header_file',
'url_encode', 'url_decode',
'url_query_encode', 'url_query_decode',
return 1;
}
+# todo text
+sub write_postdata_file {
+ (my $file, my $encoding_file, my $encoding_data, my $data) = @_;
+ my $fh;
+
+ if ($encoding_file eq '') {
+ $encoding_file = 'UTF-8';
+ }
+
+ # check if $file is actually a path or maybe a filehandle
+ # filehandles are references.
+ if(ref($file)) {
+ $fh=$file;
+ unless (seek($fh, 0, 0)) {
+ # return 0;
+ }
+ }
+ else {
+ unless (open ($fh, ">:encoding($encoding_file)", encode('locale_fs', $file))) {
+ return 0;
+ }
+ }
+
+ my $data_encoded = url_query_encode($data, $encoding_data);
+
+ print $fh $data_encoded."\n";
+
+ # If argument was a path the file must be closed.
+ unless (ref($file)) {
+ close ($fh);
+ }
+ else {
+ # cut off any remaining old file content,
+ truncate ($fh , tell($fh));
+ }
+
+ return 1;
+}
###################