On Oct 21, 4:08 am, [EMAIL PROTECTED] (Jeremy Kister) wrote:
> On 10/21/2007 1:05 AM, newBee wrote:
>
> > $userInput = <STDIN>;
> > while(chomp($userInput) ne /q/i) {
> > @lineArray = split '\W+', $userInput;
> > foreach $word(@lineArray){
> > if($DEBUG){print "<$word>\n";}
> > }
> > }
>
> while(<STDIN>){
> chomp;
> last if(/q/i);
> foreach my $word (split(/\W+/, $_)){
> print "<$word>\n" if($DEBUG);
> }
>
> }
>
> also, you probably mean /^q$/i in that first regex, otherwise you're
> matching any letter q -- quick, squid, etc
>
> --
>
> Jeremy Kisterhttp://jeremy.kister.net./
Thanks Jeremy,
I put the code that you provided it works fine, but when i alter my
code to match the concept with your code, it doesn't come out from the
control structure.. the reason I put the terms into array is that I am
planning on creating a hash with the data that user is providing as
input.
here is the code, and it will be great if you could let me know what i
am doing wrong compare to your code segments
print "Please enter term: \n";
while(chomp($userInput = <STDIN>)) {
last if(/^q$/i);
@lineArray = split '\W+', $userInput;
foreach $word(@lineArray){
if($DEBUG){print "<$word>\n";}
}
}
thanks in advance.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/