Re: global and local confusion

2008-11-25 Thread John W. Krahn
Harry Putnam wrote: "John W. Krahn" <[EMAIL PROTECTED]> writes: Harry Putnam wrote: my ($rgx,$use,@finddir); $use = shift @_; $rgx = qr/(^|:)$use /; You are using capturing parentheses but you never use the string thus captured so you may want to use non-capturing parentheses in

Re: global and local confusion

2008-11-24 Thread Chas. Owens
On Mon, Nov 24, 2008 at 15:33, Harry Putnam <[EMAIL PROTECTED]> wrote: snip > ChasO, I'm curious about something here. I noticed you put: > use File::Find; > use File::MMagic; > > Before the checkfile() call. > > In the actual working script where checkfile() will be only a minor > part it is li

Re: global and local confusion

2008-11-24 Thread Chas. Owens
On Mon, Nov 24, 2008 at 14:41, Harry Putnam <[EMAIL PROTECTED]> wrote: snip > It looks like what you've done is pass an entire sub function into > another sub function. So there ends up being 3 sub function in all. > > I see it works but I'm still a little confused about `wanted()'. > > Is it not

Re: global and local confusion

2008-11-24 Thread Harry Putnam
"Chas. Owens" <[EMAIL PROTECTED]> writes: > use strict; > use warnings; > > use File::Find; > use File::MMagic; > > my $flag = shift; > > checkfile($flag); ChasO, I'm curious about something here. I noticed you put: use File::Find; use File::MMagic; Before the checkfile() call. In the actu

Re: global and local confusion

2008-11-24 Thread Harry Putnam
"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 > lexi

Re: global and local confusion

2008-11-24 Thread Harry Putnam
"Chas. Owens" <[EMAIL PROTECTED]> writes: >> I don't understand why that happens. >> [snip] my version of script > It looks like your problem is that you are creating a named subroutine > inside another. > > I think this is close to what you desire. Yes, and I see you were able to come very cl

Re: global and local confusion

2008-11-24 Thread Harry Putnam
"Mr. Shawn H. Corey" <[EMAIL PROTECTED]> writes: [...] >> >> find(\&wanted, @finddir) or die " Failed to open >> finddir <$finddir>: $!"; > > You have not defined the scalar $finddir. You have defined the array > @finddir, but it's not the same. Sorry, yes you're right but I actually cau

Re: global and local confusion

2008-11-23 Thread Chas. Owens
On Sun, Nov 23, 2008 at 20:07, John W. Krahn <[EMAIL PROTECTED]> wrote: snip >> checkfile($flag); >> sub checkfile { >> use File::Find; >> use File::MMagic; >> use FileHandle; > > use() happens at compile time so there is no point, but no harm, to put > these inside a subroutine. snip This is n

Re: global and local confusion

2008-11-23 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Sun, 2008-11-23 at 16:55 -0600, Harry Putnam wrote: The program I'll post below is really only a test of a subroutine I want to use in a larger program. Trying to get the subroutine ironed out in this test script below so there is a little extra bumping around to ge

Re: global and local confusion

2008-11-23 Thread John W. Krahn
Harry Putnam wrote: The program I'll post below is really only a test of a subroutine I want to use in a larger program. Trying to get the subroutine ironed out in this test script below so there is a little extra bumping around to get it executed as sub routine, but It fails with these errors:

Re: global and local confusion

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 16:55 -0600, Harry Putnam wrote: > The program I'll post below is really only a test of a subroutine I > want to use in a larger program. Trying to get the subroutine ironed > out in this test script below so there is a little extra bumping > around to get it executed as sub

Re: global and local confusion

2008-11-23 Thread Chas. Owens
On Sun, Nov 23, 2008 at 17:55, Harry Putnam <[EMAIL PROTECTED]> wrote: > The program I'll post below is really only a test of a subroutine I > want to use in a larger program. Trying to get the subroutine ironed > out in this test script below so there is a little extra bumping > around to get it