Hello oxalate,
Here is a tip regarding this section of the code:
foreach my $i (@array) { if(grep @array[$i], @files) { my $match = (grep @array[$i], @files);
First of all, $i is being set to the actual filename, not your array index. Thats why nothing seems to be working properly. Try this to see what I mean:
$ perl -we ' my @array = qw( file1 file2 file3 ); foreach my $i (@array) { print "\$i = $i\n" }' $i = file1 $i = file2 $i = file3
If you want $i to contain the array index, you could use $#array which will give you the number of array elements minus one (the highest index) along with the range operator:
$ perl -we ' my @array = qw( file1 file2 file3 ); foreach my $i ( 0 .. $#array ) { print "\$i = $i\n" }' $i = 0 $i = 1 $i = 2
Also, if you want to index into an array you should do it like this: $array[0]. Not like you have it, @array[0]. The way you have written it, you are taking a slice.
This might get you a little bit closer to what you are trying to do...
Best,
Jim
In reply to Re: Parsing files in a directory using a list.
by jimpudar
in thread Parsing files in a directory using a list.
by oxalate
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |