in reply to Re^2: Reading from filehandles in a loop and matching lines
in thread Reading from filehandles in a loop and matching lines

Looks like shell error messages. Have you deleted the very first line of the script starting with #!? Then your shell tries to interpret the script, not perl.

Replies are listed 'Best First'.
Re^4: Reading from filehandles in a loop and matching lines
by Nathan_84 (Acolyte) on May 06, 2010 at 01:55 UTC

    with the first line added i get the following errors

    l symbol "$line" requires explicit package name at ./employee.pl line +10. Global symbol "$line" requires explicit package name at ./employee.pl +line 13. Global symbol "$name" requires explicit package name at ./employee.pl +line 16. Global symbol "$department" requires explicit package name at ./employ +ee.pl line 16. Global symbol "$salary" requires explicit package name at ./employee.p +l line 16. Global symbol "$line" requires explicit package name at ./employee.pl +line 16. Global symbol "$name" requires explicit package name at ./employee.pl +line 18. syntax error at ./employee.pl line 19, near "print" Global symbol "$name" requires explicit package name at ./employee.pl +line 23. Global symbol "$salary" requires explicit package name at ./employee.p +l line 26. Global symbol "$department" requires explicit package name at ./employ +ee.pl line 29. Global symbol "$name" requires explicit package name at ./employee.pl +line 32. Global symbol "$name" requires explicit package name at ./employee.pl +line 34. Execution of ./employee.pl aborted due to compilation errors.

      Declare those variables as lexical variables, i.e. put my before the first occurrence.  And put a semicolon at the end of the prints:

      ... while (my $line = <EMPLOYEES>) { chomp $line; my ($name,$department, $salary) = split /\t/, $line; print "n=$name\n"; print "d=$department\n"; print "s=$salary\n"; ...
      Yes, it is perl. It complains because you turned strict on without tindying the code. See strict. Nevertheless, you have errors in the code like missing semicolons.