For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > March 2005 > RE: valid use of while expression









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: valid use of while expression
Charles K. Clarkson

2005-03-31, 3:56 am

T Raymond <mailto:trlist@insightbb.com> wrote:

: If there is a word in $words[$n], is the following expression for
: while valid? --Teresa

Define "valid".

We can test the _syntax_: I get "a.pl syntax OK".

#!/usr/bin/perl -c
use strict;
use warnings;

my @words = split ' ', 'The quick brown fox';

my @letters;
my $n = 1;
while ( $words[$n] ) {
@letters=split//;
}

__END__


Do you want to know if the while loop is endless? Yes it is.
$words[$n] will always evaluate true until we do something to it
to make it evaluate to not true.

But these are things you could have tried yourself. So what
do you mean by "valid"?


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com