in reply to Print array values

Based on the limited information you've provided I assume you wish to execute two grep statements per filename.

But first, even though this might be a simple script, simple scripts have a habit of growing and evolving over time, so start it out properly at the beginning.
use strict *ALWAYS*
use warnings
use a standard formatting and indentation style (i like K&R)

Give this a try:
#!/usr/bin/perl use strict; use warnings; my @filename = qw{filename1 filename2 filename3}; my @data =qw{DATA1 DATA2}; foreach my $file (@filename) { foreach my $searchdata (@data) { my $cmd_results = `grep -c $searchdata $file`; print "$file | $searchdata | $cmd_results \n"; # or whatever t +ags refers to... } }

It may be worth noting that your original method would have run into problems once $i reaches 2 (and tries to process DATA3 which doesn't exist...)
Using a foreach is nice since you don't need to care about an iterator, and you can make the code more self documenting... IMHO