[boulder.pm] next in a for loop?

skazat jsimoni at totalsite.com
Mon Jun 18 22:50:44 CDT 2001


I think you have the next block thingy mixed up, the way you have it
written, 

  
           next if ($i =~ /^$/);


This will skip whatever $_ is on if it actually does have a value, instead,
just say: 
 
           next unless ($i =~ /^$/);

or 

            next if ($i !~/^$/);

you may just be able to simplify it and say:

next if(!$i);  

which is nicer and can be easilly read as  'next if no $i'


-- 
justin simoni!                                             http://skazat.com
___________________________________________________________________

We NEVER clean the toilet, Neil! That's what being a student is all about!
No way, Harpic! No way, Dot! All that Blue Loo scene is for squares. One
thing's for sure, Neil. When Cliff Richard wrote "Wired for Sound", no way
was he sitting on a clean lavatory! He was living on the limit, just like
me. Where the only place to put bleach is in your hair!
-Rick, from "the Young Ones"




On 6/18/01 9:49 AM, "Robert L. Harris" <Robert.L.Harris at rdlg.net> wrote:

> 
> 
> @content is the result of a get($url) which is populated correctly.
> 
> I have this:
> 
> 
> foreach $i (@content) {
>   next if ($i =~ /^$/);
> 
>   print "\$i :$i:\n";
> 
> }
> 
> 
> In theory, if $i is empty ( i.e. "") it should skip to the next iteration.
> I've also done a 'next $i if ($i eq "");' and a number of combinations
> of those 2.  It doesn't correctly skip the print statement.  The print
> statement is just an exampla, I actually have a good bit of processing so
> I cant just say "print if ($i ne ""); or such...
> 
> How do I get it to go to the next iteration of the loop if $i is empty?
> 
> 
> :wq!
> ---------------------------------------------------------------------------
> Robert L. Harris                |  Micros~1 :
> Senior System Engineer          |    For when quality, reliability
> at RnD Consulting             |      and security just aren't
>                               \_       that important!
> DISCLAIMER:
>     These are MY OPINIONS ALONE.  I speak for no-one else.
> FYI:
> perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
> 
> 




More information about the Boulder-pm mailing list