CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [rovf] Substitutions: Edit Log


Feb 13, 2013, 6:11 AM

Views: 1518
Re: [rovf] Substitutions

Hey, ty! I've tried something but it's not yet what i wanted cause i can't do the replacement and recover all the string with the replaced items:

use strict;
use warnings;

my $ligne = <STDIN>;
my %norm = ("one" => 1, "two" => 2, "three" => 3);
my @array = split(' ', $ligne);

foreach my $elem (@array) {
if (exists $norm{$elem}) {
print "$norm{$elem}\n";

This will only print the value of the key if it is also in the array :X
I woud like to be able to write down "bobby has two cats and one dog" and get "bobby has 2 cats and 1 dog".

(This post was edited by IsabelleFr on Feb 13, 2013, 6:13 AM)

Edit Log:
Post edited by IsabelleFr (Novice) on Feb 13, 2013, 6:13 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives