in reply to Re: Reading from filehandles in a loop and matching lines
in thread Reading from filehandles in a loop and matching lines
use warnings; use strict; open (EMPLOYEES,"employees.txt") or die "Tough: $!\n\n"; while ($line = <EMPLOYEES>) { chomp $line; ($name,$department, $salary) = split /\t/, $line; print "n=$name\n" print "d=$department\n" print "s=$salary\n" next unless$name =~ /^Mr /; next unless$salary > 25000; next unless$department eq $ARGV[0]; $name =~ s/Mr//; print"$name\n"; } close (EMPLOYEES);
The command line i used was ./employee HR. This is the whole script and there are no parameters at the start. These are the errors i am getting;
./employee.pl: line 1: use: command not found ./employee.pl: line 2: use: command not found ./employee.pl: line 5: syntax error near unexpected token `EMPLOYEES," +employees.txt"' ./employee.pl: line 5: `open (EMPLOYEES,"employees.txt") or die "Tough +: $!\n\n";'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reading from filehandles in a loop and matching lines
by choroba (Cardinal) on May 06, 2010 at 01:45 UTC | |
by Nathan_84 (Acolyte) on May 06, 2010 at 01:55 UTC | |
by almut (Canon) on May 06, 2010 at 02:03 UTC | |
by choroba (Cardinal) on May 06, 2010 at 02:02 UTC |