[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Grep help



Greetings,

	I realize there's a simple answer to this question, I'm just not
stumbling across it!

See the code sample at bottom.

I'm expecting Searchmodel to print all 3 of these models...the regex
should match '6' with each key of %Models right? But I get no matches.
If I put in 
searchModel('610') I get that match.

So what am I missing?



# Code ============================================
#! Perl
%Models = (
'610' => ['Apple','Centris','610'],
'650' => ['Apple','Centris','650'],
'660AV' => ['Apple','Centris','660av']);

searchModel('6');


sub searchModel{
print"All models:\n\n";
$searchItem = shift;
my $modelLabel;

foreach $modelLabel (keys(%Models)){
print "$modelLabel\n";

	if ($searchItem =~ /$modelLabel/i){
		print "Match with $searchItem: $modelLabel\n";
		
} #end if
}
}

Allan Greenier
AutoScript Applications

agreenier@snet.net
http://www.geocities.com/~autoscript

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org