Perl system fuction with

Hi,

I've written a perl script with a nested foreach statement in it.

I have the line

code:
foreach $argn(@arguments) {
foreach $location (@path) {
system("find $location -name \"$argn\" -print >> results.txt");

               open\(DATAFILE2, "results.txt"\) || die "cannot find results.txt file";
                    @results=<DATAFILE2>;
                    close\(DATAFILE2\);
                    \#Print results
                    foreach \(@results\) \{
                            print;
                        \}
                    system\("rm results.txt"\);
       \}

}

The problem is the system("find $location -name \"$argn\" -print >> results.txt"); seems to only return the results of system("find $location
and gives �sh: line 2: -name: command not found� error

To test if it was my code, I hardcoded the $location variable and the $argn variable, and that worked fine.

Any ideas why using the argns isn't working?

You have new line in $location.

Kindly chomp it before giving it as argument.

thanks thegeek, i feel so stupid for not noticing that.

adding
chomp($location);
chomp ($argn);

did the trick. Def need abit more practise with perl after that...

---------- Post updated at 07:06 AM ---------- Previous update was at 06:44 AM ----------

To add to this as i feel so silly,

How would you change the above unix find statement to use

File::Find