Perl script help URGENT???

Friends
I generated a code too read a list if names from file and store it in array. The file contains names of some files. like
a.txt
b.txt
c.txt ........
while I am running the script and gives a file name as argument I have to check wehere the file processed or not. if processed exit the program . Code is given below .
#!/usr/bin/perl -w
#Opening "file" for getting parsed file information
open (DATA,"+>>file") || die ("OOOps");

while \(<DATA>\) \{
	$f_name .= $_;
	\}
		@check = split\(/ /,$f_name\);
	foreach $check \(@check\) \{
		while \($check == @ARGV\) \{
print "Already processed\\n";
	exit;
\}
\}

It is not working .
What is wrong with it ..

Jagan

To help others help you, you should give more details as to how it doesn't work, and state your expected results.

Friend
I will tell it
1) Read command line argument (for the given Perl script). ( Command Line argument will be a file name)
2) Check existence of the file name in "file" . That i tried to do here open (DATA,"+>>file") || die ("OOOps");
#Open "file"
while (<DATA>) {
$f_name .= $_;
}
@check = split(/ /,$f_name);
#store the contents of "file" to @check.
print "@check\n";
foreach $check (@check) {
while ($check == @ARGV) {
print "Already processed\n";
exit;
}
#Check the presence of file name in @check.
3) if the file npresent in @check then exit
4)Else exicute other programs
Now it 1-3 is not wotking .

Jagan

First, you are reading from <DATA>. Why are you not opening it with open(DATA, "<file")?

Second, why are you doing this:

$f_name .= $_;

I guess running this in a loop will give you a string consisting of concatenating multiple lines, and you split it by space afterwards will not work because the line read from <DATA> is not chomped, and I could not see a space being added in the middle at all. So you will not get a valid @check.

Third, you should not use "while" if you mean "if".

Fourth, string comparison is not ==. You should use "eq".

Fifth, @ARGV is an array. $check is a scalar. You probably meant $ARGV[0] here. "$check == @ARGV" means checking whether @ARGV has the number of elements equals the value of $check. That doesn't seem to make sense here.

I think your program is full of errors. Please kindly revise your Perl learning materials and fix the errors accordingly.

Collegue
Thank you for your kind advice and guidence. I solved the peroblem. My code is given below..
$parse = @ARGV[0];
open(DATA,"+<file") || die ("failed to open");
@files = <DATA>;
foreach $files (@files) {
if ($files =~ m/$parse/) {
print "Already processed file\n";
sleep 10;
exit;
}
}

It is working fine now

Jaggu