akirostar has asked for the wisdom of the Perl Monks concerning the following question:
data.txt#!/usr/local/bin/perl -w use strict; open(INPUT, "data.txt") || die "Error opening 'keywd.txt'\n"; my @data = <INPUT>; open(FH, '<', "keywd.txt") || die "Error opening 'data.txt'\n"; my @keywd = <FH>; my $keywdnum = $#keywd; while (my $element = pop @data) { my $i = 0 ; chomp($element); while ($i <= $keywdnum-1) { my $tempwd = ""; $tempwd = $keywd[$i]; if ($element =~ m/$tempwd/i) { print $i; $i++; } else { $i++; } } } close INPUT; close FH;
keyword.txtanalysis data power seek true
analysis analyzing applications co-principal completed computer computing consulting data
|
|---|