Solved

unless

Posted on 2003-10-29
1
298 Views
Last Modified: 2010-03-04

# Skip to numbers.
BEGINNING: while ($begin = shift @a) {
  print qq (inspecting $begin\n);
  #last BEGINNING if $begin =~ /BEGIN/;
  next BEGINNING unless $begin =~ /BEGIN/;
}

last with the if statement works fine.
What's wrong with the unless.  It doesn't ever
break out.  Thanks.
0
Comment
Question by:hank1
1 Comment
 
LVL 2

Accepted Solution

by:
ultimatemike earned 50 total points
ID: 9641968
For starters - Your "BEGINNING" label is the start of a while loop. It technically is working.  The unless statement is working and it's not going to beginning. However, the next command that it will execute will be starting the next iteration of the loop.

What your unless statement is saying is :  "Go to beginning, unless it matches the regular expression. But if it matches the regular expression, go to the start of the loop".  So both cases actually do the same thing.  The last statement with the if is probably the way you want to do it :)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question