Or even just putting "$count" as the last statement should do the trick as that is the last scalar assignment in a subroutine that automatically gets returned.
-- Rex ----- Original Message ----- From: "Jos I. Boumans" <[EMAIL PROTECTED]> To: "MerryChristmas!" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, November 16, 2001 4:04 AM Subject: Re: sub-routine help needed. > > Sigh ! My mind simply refuses to work. What must I do to print the number > of > > records $count in line 3. > > Thanks > > > > > > 1. @array = qw ( hello world hello how are you ); > > 2. $match = 'HEllo'; > > 3. print "Your search for $match returns $subroutine $count > > records<br>\n"; > > > $subroutine = &count; > > sub count { > > foreach $record (@array){ > > if (grep /$match/i, $record) { > > print $record; > > $count++; > > }; > > }; > ### add this: > return $count; > > > }; > > > > > > you simply 'return' what you want to return ;) > try 'perldoc -f return' > > hth, Jos > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]