"John W. Krahn" <[EMAIL PROTECTED]> writes:

> Harry Putnam wrote:

[...]

>>   Variable "$rgx" will not stay shared at ./test line 30.
>
> perldoc perldiag
> [ snip ]
>
>     Variable "%s" will not stay shared
>         (W closure) An inner (nested) named subroutine is referencing a
>         lexical variable defined in an outer subroutine.
>

[...] The snipped part makes it clear what is happing that makes this
an error... thanks

[...]

>
>>   Global symbol "$finddir" requires explicit package name at ./test line
>>   19.

Sorry, that one wasn't supposed to make it into my post.  I was working
in 3 terminals remotely and got myself confused. More than on `screen'
buffer contained the working script.  I just didn't notice that the
old version and its  error output was what I pasted into the post.

[...] Thanks for the snipped full reference documentation. 

Harry wrote:
>>   my ($rgx,$use,@finddir);
>>   $use = shift @_;
>>   $rgx = qr/(^|:)$use /;      

JohnK replied:
> You are using capturing parentheses but you never use the string thus
> captured so you may want to use non-capturing parentheses instead.

What are non-capturing parens?

By `capturing' do you mean `(^|:)$use '?

I was shooting for a regex that finds both of these:

$matchofrgx bla bla bla
    and
bla bla bla:$matchofrgx

I'm really not sure what you meant there so I'm probably missing your
point. 

>>  find(\&wanted, @finddir) or die "   Failed to open
>>   finddir <$finddir>: $!";
>
> @finddir and $finddir are two different variables and $finddir does
> not exist yet.  File::Find::find() does not explicitly return a value
> so testing for its failure is superfluous, and if it did, by
> coincidence, return a value then it would do so after all files had
> already been processed by the 'wanted' subroutine and it could be any
> random value. In other words, the value that may be returned by
> File::Find::find() has no relation to the success or failure of
> File::Find::find().
>

I didn't realize my `die' was completely misplaced.. .. Thanks.  I
guessed that the line:

>>  find(\&wanted, @finddir) ....

Would fail like an open() does since it does open that list of
directories.  Thanks for the headsup.. I've used that at least twice
before but the program didn't fail so I never caught on.  ... thanks

>>   sub wanted {
>
> Subroutine names are in package scope so defining a named subroutine
> inside another named subroutine makes little sense.

I'm pretty confused about this scope business.  What do you mean
there?  What does it mean to say something is in package scope?

Or maybe you can direct me to the right perldoc output to get cleared
up on that a little better.

[...]

>>     if ($res =~ /^plain\/text/) {
>>       open(FILE,"<$File::Find::dir") or die "Can't open
>> <$File::Find::dir>: $!"; 
>
> $File::Find::dir is the current directory where the file name in $_ is
> found and open() will only open files, not directories.  If you want
> to open a directory you have to use opendir() instead, but that is
> pointless as File::Find::find() is already providing you with all the
> file names via $_.
>

That was supposed to have said File::find::name.   I used
File::find::dir a little further along (correctly) but still didn't
notice the earlier misuse, the earlier errors stopped the script so
that never came out in the error messages.

Many thanks for the careful and referenced walk thru... very helpful.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to