Search Results

Search found 3 results on 1 pages for 'aliocee'.

Page 1/1 | 1 

  • How to search for alphanumeric word before or after a keyword in perl?

    - by aliocee
    I have sentences as shown in the below examples: $sen1 = "The quick brown fox jump KEYWORD over123 the3 lazy dog, fox is quick"; $sen2 = "The quick brown fox jump123 KEYWORD over the lazy dog, fox is quick"; i want to use the keyword 'KEYWORD' as my search string to extract the alphanumeric words before and after the search string using Perl regular expression. sample output: over123 jump123 NB: The word 'the3' is left out because i'm only searching for alphanumeric words exactly before or after the 'KEYWORD'. Thanks

    Read the article

  • How can i pass Twig sub parameter?

    - by aliocee
    hi, Help i cant pass my hash key to twig subroutine. here: foreach my $word (sort { $keywords{$a} <=> $keywords{$b} } keys (%keywords)) { my $t = XML::Twig->new( twig_roots => { 'Id' => \&insert($keywords{$word}) } ); $t->parse($docsums); sub insert { my($t, $id, $k)= @_; my $p = $id->text; my $query = "insert into pres (id, wid, p) values(DEFAULT, '$k', '$p')"; my $sql = $connect->prepare($query); $sql->execute( ); } } Thanks.

    Read the article

  • Majority Voting in perl?

    - by aliocee
    Hi, i have 5 files containing the same words, i want read each word in all files and decide the winning word by detecting the following characters in a word (*, #, $, &) and generate output file i can only have 2 winners for example: file1 we$ are* ... file2 we$ are* ... file3 we* are$ ... file4 we$ are$ ... file5 we# are& ... output file: we$ - we$ is the winner since it occur in 3 files. are*$ - are* and are$ are the winners since both occur 2 times. here is how i started: #!/usr/local/bin/perl -w sub read_file_line { my $fh = shift; if ($fh and my $line = <$fh>) { chomp($line); return $line; } return; } open(my $f1, "words1.txt") or die "Can't"; open(my $f2, "words2.txt") or die "Can't"; open(my $f3, "words3.txt") or die "Can't"; open(my $f4, "words4.txt") or die "Can't"; open(my $f5, "words5.txt") or die "Can't"; my $r1 = read_file_line($f1); my $r2 = read_file_line($f2); my $r3 = read_file_line($f3); my $r4 = read_file_line($f4); my $r5 = read_file_line($f5); while ($f5) { what can i do here to decide and write the winning word in the output file? $r1 = read_file_line($f1); $r2 = read_file_line($f2); $r3 = read_file_line($f3); $r4 = read_file_line($f4); $r5 = read_file_line($f5); } Thanks.

    Read the article

1