Fouled Script

Harry Schroeder has3 at usa.net
Tue Jan 8 08:56:53 CST 2002


You will most likely see the problem if you use the perl debugger and x 
$MFILES after the assignment.

Because you are using "'s , the \( is interpreted differently than you 
probably expect.

Take a look at the variable in the debugger, and you will understand. To 
fix try \\( and \\) .

Harry

SoloCDM wrote:

>Eric Schwartz stated the following:
>
>>On Mon, Jan 07, 2002 at 12:25:24AM -0700, SoloCDM wrote:
>>
>>>The attached script is my first attempt at some means of perl
>>>scripting, base on your advice.  It won't work.  I keep getting the
>>>following error:
>>>
>>>syntax error at ./find-perl-sample2 line 8, near "open " Execution
>>>of ./find-perl-sample2 aborted due to compilation errors.
>>>
>>Unquoted string "directory" may clash with future reserved word at
>>find-perl-sample line 4.  Scalar found where operator expected at
>>find-perl-sample line 5, near "$MFILES" (Missing semicolon on previous
>>line?) syntax error at find-perl-sample line 5, near "$MFILES "
>>find-perl-sample had compilation errors.
>>
>>Essentially, you're missing a bunch of semicolons, and if [directory]
>>isn't what you really put there, you should tell us, so we know
>>what you actually are asking about.  Otherwise, you should quote it
>>properly.  Furthermore, by using [directory], you're creating an
>>arrayref, and I don't think that's what you wanted to do there.
>>
>
>Now I am getting the error below with the attached file:
>
>sh: -c: line 1: syntax error near unexpected token `('
>sh: -c: line 1: `find / -type f -ls -xdev -fstype ext2 ( -iname
>'*personal*' -o -iname '.*personal*' ) -print'
>
>I hope all the semicolons are in place; although, previously to
>sending the first posting -- I put all the semicolons as expected, but
>I still didn't get a correct response from the script.
>
>
>------------------------------------------------------------------------
>
>#!/usr/bin/perl -w
>#
>
>$MDIR = "/";
>$MFILES = "find $MDIR -type f -ls -xdev -fstype ext2 \( -iname '*personal*' -o -iname '.*personal*' \) -print";
>
>open FIND, "$MFILES |" or die $!;
>while( <FIND> ) {
>	# $_ will have each file name found with full path name
>	# do what you want with it here
>	print "$_\n";
>}
>close FIND;
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/pikes-peak-pm/attachments/20020108/aa863ec3/attachment.htm


More information about the Pikes-peak-pm mailing list