in reply to input tab delimited file
I'm not entirely sure what your trying to achieve as you seem to be reading from both files and writing back to one, but hopefully this will put you more on the right track
1) I think your copy and pasting has added some things you don't need nor use, this will harm your understanding. Please remove.
use IO::File; use LWP::Simple;
You really don't seem to need them for this task
2) What exactly are you doing with your input and output files? they seem to be the wrong way round ? you seem to be attempting to read from your output file (even though you haven't opened them correctly. If you want to read from 'input.txt' and write to 'output.txt' you would do something like this.
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;
Now you are in a position to read from the files, so maybe something like this
while(my $line = <INPUTFILE>) { $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/, $li +ne);# See the variables have been declared # .. do something here }
|
---|