14 Write - Two base methods for writing information.
18 This module contains three methods for writing information into a program. They allow the writing of information from a string or filename and expect the method write() to be defind by the class that inherits this module.
22 =head2 write_file($path)
24 Opens a file at the given path and then calls the write method.
26 =head2 write_gzip_file($path)
28 Like write_file, but compresses the output using the system gzip command.
30 =head2 write_string($scalar)
32 Writes the data in the scalar and passes it to the write method.
34 =head2 write($filehandle)
36 This method will cause a fatal error unless it's overidden by the class that inherits this module.
41 confess "The inheriting package hasn't defined the write() method\n";
45 my ( $self, $fn ) = @_;
47 open my $fh, ">$fn" or confess "Can't open file $fn: $!";
53 my ( $self, $fn ) = @_;
55 my $gzipd_fn = File::Temp->new->filename;
57 $self->write_file($gzipd_fn);
59 system "gzip -c $gzipd_fn > $fn";
66 $self->write( IO::String->new($string) );