Array manipulation in perl

hi all,

i am trying to append the output of a find command (for different paths)in an array as below...

my $res_array;
$i=0;
$dir="/orn/ops/regs";
foreach $block("am","xb"){

$bdir="$dir/$block";

$res_array[$i]=`find $bdir ! -user mainuser -printf \"\%u \%h\\n\"`;

$i++;

}

i tried this but it is not saving anything in the array.i want the result of find command to be saved in the array for both "am" and "xb".

i also tried to push one array into the master array, but its also not appending but overwriting.

need help here,,
thanks in advance

$res_array[$i]=`find $bdir ! -user mainuser -printf "%u %h\n"`;

tyler_durden

your not defining your array as an array.

my $res_array;

you need to define it something like

my @res_array =  ();

this aside, try to use Perl's own File::Find module.

Unless they are using strict that will not matter. Perl will create the array @res_array automatically. Of course they should be using strict. :wink:

By mistake i wrote in this thread $res_array, in the script i had declared it as
@res_array only. but then also its not working....

is there any other way to do this..

Does the "find" command return anything when run at the prompt, without the escape characters, for the values of $bdir as set in the loop ?

tyler_durden