14 Read - Two base methods for reading information.
18 This module contains three methods for reading information into a program. They allow the reading of information from a string or filename and expect the method read() to be defind by the class that inherits this module.
22 =head2 read_file($path)
24 Opens a file at the given path and then calls the read method.
26 =head2 read_file_gzip($path)
28 Calls read_file after decompressing a gzip compressed file using the system gzip command.
32 Accessor for finding where a file was located.
34 =head2 read_string($scalar)
36 Reads the data in the scalar and passes it to the read method.
38 =head2 read($filehandle)
40 This method will cause a fatal error unless it's overidden by the class that inherits this module.
45 confess "The inheriting package hasn't defined the read() method\n";
49 my ( $self, $fn ) = @_;
51 open my $fh, $fn or confess "Can't open file $fn: $!";
56 =head2 read_gzip_file($scalar);
58 Like read_file($scalar), but ungzip's the file first.
63 my ( $self, $fn ) = @_;
65 my $gzipd_fn = File::Temp->new->filename;
67 system("gzip -dc $fn > $gzipd_fn");
69 $self->read_file($gzipd_fn);
73 my ( $self, $string ) = @_;
75 my $fh = IO::String->new($string);