#!perl -w
use strict;
# Searching for motifs, Counting ACGT and errors
# documentation written in pod, perldoc perlpod
=head1 NAME
read_file.pl
=head1 DESCRIPTION
Read and print files.
=head1 SYNOPSIS
read_file.pl ...
=cut
while (my $filename = shift @ARGV) {
my $sequence = slurp($filename);
print "$filename:\n";
print_dna($$sequence);
}
# \$data = slurp($filename);
# slurp in all data into a single variable
# return a reference to avoid copying data
# Recommend: File::Slurp library for this
# This function was benchmarked with reading an array and reading lines
# On a slow PC, it quickly out paced arrays, and did better than lines.
sub slurp {
my ($filename) = @_;
my $inf;
local $/;
open($inf, "< $filename") or die("Unable to open $filename: $!");
my $buf = <$inf>;
close $inf;
return \$buf
}
# sub to print the DNA onto the screen
sub print_dna {
my $dna = shift;
print $dna,"\n";
}