Matt Herzog wrote:
> Hey all.

Hello,

> I'm trying to write a script that will append a few chars (example _fr) to
> the end of the "prefix" filename. All the filenames I need to change end with
> .properties. I need to have this script descend into all subdirs of the dir
> specified at the command line.
> 
> I can't seem to understand how to use a variable with the find(\&wanted
> syntax from File::Find. I suppose I can substitute "wanted" with &$whatever ?
> So far it does not work.

In the example find( \&wanted, 'dir' ) 'wanted' is the name of a subroutine
and \&wanted is a reference to that subroutine.  If you want to use $whatever
you would do it something like this:

my $whatever = sub { # store sub reference into $whatever
    # your code here
    }

find( $whatever, 'dir' );


If you want to use a subroutine named 'whatever' then:

sub whatever {
    # your code here
    }

find( \&whatever, 'dir' ); # pass a reference to 'whatever'


Or you could just use an anonymous subroutine directly:

find( sub { your code here }, 'dir' );




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

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


Reply via email to