<?xml version="1.0" encoding="windows-1252"?>
<node id="981995" title="Syntax error in using do-until loop: How can I fix it?" created="2012-07-16 06:12:03" updated="2012-07-16 06:12:03">
<type id="115">
perlquestion</type>
<author id="942579">
supriyoch_2008</author>
<data>
<field name="doctext">
&lt;p&gt;Hi Perl Monks,&lt;/p&gt;
&lt;p&gt;I am a beginner in perl script writing. I have written a small script &lt;code&gt;word.pl&lt;/code&gt; (given below) using a do-until loop to chop a sentence
in 4-letter words. But it is not showing the results. The line number 22 shows a syntax error for ");". I 
have not been able to correct the error. I have written line number 22 to search the sentence fron beginning 
to the end for every 4-letter word. May I expect suggestions from perl monks regarding the error?
The script goes like:&lt;/p&gt; 

&lt;code&gt;#!/usr/bin/perl-w 
## To chop a sentence at intervals of 4-letter and to print results:
use strict;
my $sentence="BEAR CALF DEER FEAR GEAR HEAR";
## To remove blank spaces:  # Line 5  
$sentence=~ s/\s//igs;
print"\n Words are:  \n";
do {
my @four=$sentence=~ /[a-zA-Z]{4}/igs; # Line 9 
foreach my $word(@four)
   {print"\n $word: ";
   my $length=length($word);
   print"\n Length of the word= $length\n\n";
my $output="Words .txt";                  # Line 14 
unless (open(RESULT,"&gt;$output")){
print"Cannot open file\"$output\".\n\n";   # Line 16
exit;
}
print RESULT"\n Words are:  \n
 Word: $word; Length of the word= $length\n\n";
close(RESULT);  # Line 21 
} until ( my $word=~ /^.*$/); # Line 22  
exit;
}&lt;/code&gt;

&lt;p&gt; I have got the following results in cmd screen:&lt;/p&gt;

&lt;code&gt;Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Users\xxxxxxx\Desktop&gt;word.pl
syntax error at C:\Users\xxxxxx\Desktop\word.pl line 22, near ");"
Execution of C:\Users\xxxxxxxx\Desktop\word.pl aborted due to compilation errors.&lt;/code&gt;</field>
</data>
</node>
