use strict; use warnings; #### my $linkFile = q{linksource.dat}; open my $linkFH, q{<}, $linkFile or die qq{open: $linkFile: $!\n}; my $rhTitleToURL = {}; LINKLINE: while (<$linkFH>) { next LINKLINE unless m {(?x) title\s*=\s*" ([^"]+) .*? href\s*=\s*" ([^"]+) }; my ($title, $url) = ($1, $2); $rhTitleToURL->{$title} = $url; } close $linkFH or die qq{close: $linkFile: $!\n}; #### my @fields = split m{\s*,\s*}; #### open old SQL file for reading open new SQL file for writing while loop reading old SQL line by line split line into fields if this is a line to be modified modify fields construct new line print to new SQL file else re-construct old line print to new SQL file close files