jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:
Ain't no time to hate! Barely time to wait! ~RH#!/usr/local/bin/perl -w use strict; my @a=(9,8,1); my (@names,@name_nums); @names=name_nums(@a); print "@names"; sub name_nums { my (%list,@name_nums,$this_num); @list{1..9}=qw(one two three four five six seven eight nine); foreach $_ (keys (%list)){ if (exists $list{$_}){ $this_num = $list{$_}; push (@name_nums,$this_num); }else{ push (@name_nums,$_); } } return @name_nums; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: matching input to hash keys
by merlyn (Sage) on Sep 30, 2001 at 02:36 UTC | |
|
Re: matching input to hash keys
by Ovid (Cardinal) on Sep 30, 2001 at 02:09 UTC | |
|
Re: matching input to hash keys
by blakem (Monsignor) on Sep 30, 2001 at 02:12 UTC |