W
Winston
I need to *MAKE* some subrutines for search inside a hash.
I wonder what is the best for this.
For example, I have a hash with names and ages. And I need to make some
searches using regular expressions...
sub a_option {
%hash = @_;
print "Letter? ";
chomp($letter = <STDIN>);
@names = keys(%hash);
$found=0;
foreach $name (@names) {
if ($name =~ /^$letter/) {
print "Name: $name\t\t Age:$hash{$name}";
$encontrado++;
}
}
}
And the same for b_option, c_option, etc...
Is this ok? Or is a little bit ridiculous?
Is correct to do: %hash=@_ ?
These are my first steps in PERL. Is this the correct group?
Don't reply with a 1-line-perl-code that make all I need!
Thanks!
I wonder what is the best for this.
For example, I have a hash with names and ages. And I need to make some
searches using regular expressions...
sub a_option {
%hash = @_;
print "Letter? ";
chomp($letter = <STDIN>);
@names = keys(%hash);
$found=0;
foreach $name (@names) {
if ($name =~ /^$letter/) {
print "Name: $name\t\t Age:$hash{$name}";
$encontrado++;
}
}
}
And the same for b_option, c_option, etc...
Is this ok? Or is a little bit ridiculous?
Is correct to do: %hash=@_ ?
These are my first steps in PERL. Is this the correct group?
Don't reply with a 1-line-perl-code that make all I need!
Thanks!