in reply to sub-routines

Hi,
your are using $line too much.
For each individual scope you should add  my $line;.
#!/usr/local/bin/perl -w use strict; use warnings; open (INFILE, "<$ARGV[0]") or die "unable to open file"; open (OUTFILE, ">$ARGV[1]") or die "unable to open file"; while (<INFILE>) { my $line = $_; print OUTFILE replace($line); } sub replace { my $line = shift; chomp ($line); $line =~ s/data//; $line =~ s/=//; $line =~ s/detector//; return $line."\n"; } close(INFILE); close(OUTFILE);
Sorry, pasted the wrong statement.
Now it is correct.

Replies are listed 'Best First'.
Re: sub-routines
by Abigail-II (Bishop) on Nov 28, 2002 at 12:54 UTC
    Your code doesn't make any sense. You're manipulating all the lines of the input, and then you discard them. Also, your replace subroutine just returns the number of arguments passed.

    Abigail