If I understand your question correctly, the following code should translate certain Spanish words into numerical values:
#!/usr/bin/env perl use warnings; use strict; my %table = ( barra => '/', cero => 0, uno => 1, dos => 2, tres => 3, cuatro => 4, cinco => 5, seis => 6, siete => 7, ocho => 8, nueve => 9 ); while (<DATA>) { if (/##(.*)##/) { my @words = split /\s+/, $1; my $pre = $`; my $post = $'; for (@words) { for my $key (keys %table) { if ($_ eq $key) {$_ = $table{$key}} } } print "$pre##", "@words", "##$post"; } else { print; } } __DATA__ (5/4/07 1:44:44 PM CDT) 7782719:##uno seis uno + + ##;pp (5/4/07 1:45:29 PM CDT) 7819953:##uno cinco cuatro##;pp (5/4/07 1:45:29 PM CDT) 7821389:##uno seis uno + + ##;pp (5/4/07 1:48:01 PM CDT) 7976990:##uno seis uno + + ##;pp (5/4/07 1:48:01 PM CDT) 7979657:## tres empaques##;pp (5/4/07 1:48:16 PM CDT) 7980901:##uno seis uno + + ##;pp (5/4/07 1:48:33 PM CDT) 8007951:##Tome tres empaques ##;pp (5/4/07 1:48:48 PM CDT) 8010439:##BEEP (375,2)## (5/4/07 1:48:48 PM CDT) 8011336:##Selección completa. ##;pp (5/4/07 1:48:48 PM CDT) 8012745:## andén Anden uno tres cinco##;pp

Produces this output:

(5/4/07 1:44:44 PM CDT) 7782719:##1 6 1##;pp (5/4/07 1:45:29 PM CDT) 7819953:##1 5 4##;pp (5/4/07 1:45:29 PM CDT) 7821389:##1 6 1##;pp (5/4/07 1:48:01 PM CDT) 7976990:##1 6 1##;pp (5/4/07 1:48:01 PM CDT) 7979657:## 3 empaques##;pp (5/4/07 1:48:16 PM CDT) 7980901:##1 6 1##;pp (5/4/07 1:48:33 PM CDT) 8007951:##Tome 3 empaques##;pp (5/4/07 1:48:48 PM CDT) 8010439:##BEEP (375,2)## (5/4/07 1:48:48 PM CDT) 8011336:##Selecci&#65533;n completa.##;pp (5/4/07 1:48:48 PM CDT) 8012745:## and&#65533;n Anden 1 3 5##;pp

This may not be the most efficient way to do this, considering that you have large files, but our fellow Monks will no doubt be able to help you optimize this.


In reply to Re: Substitution in conjunction with split or regx by toolic
in thread Substitution in conjunction with split or regx by qnguyen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.