Once again, I wish to Thank  => John W. Krahn, Paul Johnson & Charles K.
Clarkson for the latest solution which is what I want.

I also wish to Thank the following :-

Jos , for telling me about 'return' function,
Rex Arul, for telling me about returning the last value of a subroutine,
Andrea Holstein, for alerting me about other uses of grep function,
and all The Members that responded.

and last but not least =.> to all fellow members for I know you would like
to help too, thats why you are here.

Co-incidentally, before I received the final solution, last night as I was
in the bed pondering about the problem, suddenly I got the solution as I
toyed upon what Andrea Holstein & Charles K. Clarkson constant reminder (in
the previous msg; long time ago ) says about the grep function. I then take
a quick look on the grep syntax & my solution is as follows, which is very
much similar to the final solution given by Members :-

#!d:\perl\bin\perl.exe -w
use CGI::Carp qw(fatalsToBrowser);
use strict;

print "content-type: text/html\n\n";
@array = qw ( hello world hello how are you );
my (@array , @filtered, $match );

$match = 'HEllo';
@filtered = grep /$match/i, @array;

print "Your search for $match returns ", scalar @filtered," records.<br>\n";
print (join '<br>', @filtered);


Thanks !

#### end of msg ###


----- Original Message -----
From: "John W. Krahn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, November 17, 2001 7:06 PM
Subject: Re: sub-routine help needed.


> Leon wrote:
> >
> > First I would like to Thank ALL the Members for the help !
> > Secondly I would like to Thank those that urge me to use "use strict" &
> > "my".
> >
> > Unfortunately I think a lot of members have misunderstood my
earlier-first
> > question.
> > My question is:- what must I do so that the output layout would look
like
> > this :-
> >
> > Your search for HEllo returns 2 records.
> > hello
> > hello
> >
> > ### Given the following #####
> > @array = qw ( hello world hello how are you );
> > $match = 'HEllo';
> > #######################
> >
> > --- and this is what I've done but not to my satisfaction ------
> > --- because the foreach-loop run twice and I was thinking --
> > --- is there a way to come out with a better subroutine so --
> > -- that I need not have to overwork the server to run double
> > time ------------
> >
> > [snip code]
>
>
> #!d:\perl\bin\perl.exe -w
> use strict;
>
> my @array = qw ( hello world hello how are you );
> my $match = 'HEllo';
> my @found = "@array" =~ /\b\Q$match\E\b/ig;
> print "Your search for $match returns ", scalar @found, "
> records.<br>\n";
> print "$_\n" for @found;
>
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to