Find countries in a file's text using regular expressions and Perl
If you have a file with multiple rows of columns such as: RowID, year, address, journalist separated by tabs, how would you create a report of the rowID, year , country the article was written in? #!/usr/bin/perl use Uniq; $file = "The_text_file_with_addresses.txt"; $filename = $file ; $filename =~ s/\.txt// ; open OUTFILE, "+>$filename.out.txt" or die $!; open INFILE, $file or die $!; print "running...\n" ; close(OUTFILE); $docs = 0 ; while (<INFILE>) { my @agents ; $currentline = $_ ; chomp $currentline ; ( $row_id , $year, $address, $journ) = split(/\t/,$currentline ); if ($address =~ /(Afghanistan|Akrotiri|Albania|Algeria|American Samoa|Andorra|Angola|Anguilla|Antarctica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier Islands|Australia|Austria|Azerbaijan|Bahamas, The|Bahrain|Bangladesh|Barbados|Bassas da India|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Bouvet Islan...