Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Referene to Subroutine Reference

Status
Not open for further replies.

NorthernHeights

Programmer
Nov 18, 2010
3
US
I have a tough nut that I have not been able to crack. Any help would be apprecriated. I'm using File::Find.

Inside the wanted function of the find command I want to build a data structure and pass it back. I have even tried making the data structure global but doesn't work either.

Here is what I'm calling:
find( {wanted => \&GetFiles, follow => 1}, $ReducedSearchPath);

Here is the approx syntax of what I want to do:
find( {wanted => %{$PossibleMatches} = \&GetFiles(\%PossibleMatches), follow => 1}, $ReducedSearchPath);

sub GetFiles {
my $HashRef = shift @_;
my %FoundFiles = %{$HashRef};

# Make some modifications to %FoundFiles

return \%FoundFiles;
}

And ideas? I can't seem to get it to work. I don't know if it's my syntax of the find command.

Many thanks
 
I don't use File::Find, but from a quick look into perldoc it seems that you are out of the way.
perldoc said:
The wanted function. ... In fact, its return value is ignored.
The wanted function takes no arguments...
Anyway your use of references in subs is incorrect, if not wrong. You don't need to copy the hash inside the sub, just modify it (unless you really want to keep the original) and don't need to return its reference, the hash is already modified.

Franco
: Online engineering calculations
: Magnetic brakes for fun rides
: Air bearing pads
 
Thanks. I looked at the docs but not specifically for that. Too close the problem and not checking my basics.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top