Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This dutifully prints each file it finds under the current working directory. However if I commend out the find command and just call that sub directly:#!/usr/bin/perl use File::Find; find (\&testy, "."); sub testy { print $_; }
it does not print 'i am a nice parameter'. This made sense to me before using File::Find since I know that subroutines have @_, not $_, even when only a single parameter is passed.#!/usr/bin/perl use File::Find; #find (\&testy, "."); testy ('i am a nice parameter'); sub testy { print $_; }
I feel like I'm missing a simple but important concept. Any input would be greatly appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Find and $_ in the wanted sub
by ikegami (Patriarch) on Jun 04, 2010 at 20:04 UTC | |
by rastoboy (Monk) on Jun 04, 2010 at 20:28 UTC | |
by ikegami (Patriarch) on Jun 04, 2010 at 21:48 UTC | |
by bart (Canon) on Jun 06, 2010 at 13:03 UTC | |
|
Re: File::Find and $_ in the wanted sub
by almut (Canon) on Jun 04, 2010 at 20:52 UTC | |
|
Re: File::Find and $_ in the wanted sub
by toolic (Bishop) on Jun 04, 2010 at 20:27 UTC | |
|
Re: File::Find and $_ in the wanted sub
by chuckbutler (Monsignor) on Jun 04, 2010 at 20:31 UTC | |
by ikegami (Patriarch) on Jun 06, 2010 at 19:15 UTC | |
|
Re: File::Find and $_ in the wanted sub
by YuckFoo (Abbot) on Jun 04, 2010 at 21:17 UTC | |
by rastoboy (Monk) on Jun 05, 2010 at 21:34 UTC |