Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: File::Find in a loop

by Laurent_R (Abbot)
on Apr 28, 2013 at 21:05 UTC ( #1031111=note: print w/replies, xml ) Need Help??


in reply to File::Find in a loop

I haven't tested it, but I guess you could simply pass a parameter to your wanted call-back function:

my @dir = ( qw( N:/TMP N:/TMP_2 )); for my $dir ( @dir) { find( \&wanted ($dir), $dir ); }

And modify the wanted function as follows:

sub wanted { my $dir = shift; print "[$dir] $File::Find::dir $File::Find::name\n"; }

Replies are listed 'Best First'.
Re^2: File::Find in a loop
by 2teez (Priest) on Apr 28, 2013 at 21:45 UTC

    find( \&wanted ($dir), $dir );
    No! I don't think so.

    The File::Find documentation makes this clear saying thus:

    wanted function takes no arguments but rather does its work through a collection of variables.
    $File::Find::diris the current directory name,
    $_is the current filename within that directory
    $File::Find::nameis the complete pathname to the file.
    These variables have all been localized and may be changed without affecting data outside of the wanted function.

      Yes, you are right, what I suggested does not work. It has been a long time since I last looked at the File::Find documentation, I did not remember at all about that.

      Sorry about my mistake and thank you, 2teez, for pointing out this error.

      Having said that, this is (as far as I know) the first time that one of my posts had a negative reputation (-1 as of this reading). OK, well, my mistake, someone down voted me, I should know better, fair enough. I should add that I am not particularly concerned about that (and I only partly understand the reputation thing). But I did not think that an error in a post where I said that this just *might* be a solution and in which I very specifically said that this was untested deserved a down voting. But, of course, someone out there thinks that none should talk unless she or he knows everything about every single module. Oh, well...

        But, of course, someone out there thinks that none should talk unless she or he knows everything about every single module.

        No. Just those you offer help for.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031111]
help
Chatterbox?
[Corion]: perldigious: That seems to be more the export and likely it's the recipients of that export that like the titles changes
[Corion]: ... "changed"
[Corion]: I usually expect fixed header names, but am sometimes lenient in the order of columns. But changing the report titles often sounds to me as if you are not the sole consument of the export ;)
[shmem]: perldigious: as always - if it ain't broke, don't fix it. Ther must be a very compelling reason for changing column names in a database. Those are rare.
[Corion]: If you have whitespace in the column names in the database, whap the DBAs ;)
[shmem]: It's common for some vendors to have column names such as WRSTVG or some other such whizzbang, and another table where these names are mapped to something meaningful depending on how you look at the data
[shmem]: afair in SAP that occurs all the time

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-05-25 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?