I am having trouble with a simple sub-routine that i wrote. All it does is
remove some unwanted characters from a file by substituting them with nothing.
The problem is that when I call the sub-routine, i assign it to
a variable called @derivative. When i print @derivative, i expect it
to print the whole of the file, but infact it only prints
the last section. Is there an obvious reason for this that I can't see???
Any help vastly appreciated ................
#! /usr/bin/perl -w
use strict;
open (INFILE, $ARGV[0]) or die "unable to open file";
open (OUTFILE, $ARGV[1]) or die "unable to open file";
my $line;
my @derivative = replace($line);
print "@derivative\n";
sub replace {
$line = @_;
while (<INFILE>) {
$line = $_;
chomp ($line);
$line =~ s/data//;
$line =~ s/=//;
$line =~ s/detector//;
}
return $line;
}