mgwump has asked for the wisdom of the Perl Monks concerning the following question:
I am new to coding in Perl. I’m using for each and while code to read in a string from a file and isolate a 4 digit number in that string and use it in a sql query. I bring back the results of the query and append the results of the query to that string I read and got the number from.
My problem is that it performs everything I want one time, but repeats the same query results for the remaining strings that are written. It should have different query results b/c the number in the next string that is read will be different. My dB connect and sql code works fine. The trouble, I think, is here in looping the read/append of string + query.Open $fh for reading Open $fh3 for writing While (my $var = <$fh>) { Chomp $var; my @array1 = $var =~ (/Entry\s*(\d*)/); foreach my $e (@array1) } &querysub; Open $fh for reading While (<$fh>) } if ($_ =~ /(.*Entry\s*\d*)(.*)/); print $fh3 $1.” “.$qresult.$2.”\n”; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading and writing back an updated string
by roboticus (Chancellor) on Jun 26, 2019 at 20:35 UTC | |
|
Re: Reading and writing back an updated string
by poj (Abbot) on Jun 26, 2019 at 20:56 UTC |