use IO::File; use LWP::Simple; #### open(INPUTFILE, "< input.txt") or die "cannot open file for reading $!"; open(OUTPUTFILE, "> output.txt") or die "cannot open file for writing $!"; ..... code goes here close INPUTFILE; close OUTPUTFILE; #### while(my $line = ) { $line =~ s/&+/&/; # Assuming you have a good reason for this # See $line has now been declared, where before it wasn't my ($isbn, $ocln, $title, $author, $call_number) = split(/\t/, $line);# See the variables have been declared # .. do something here }