Nathan_84 has asked for the wisdom of the Perl Monks concerning the following question:
Hi folks :) I've been working my through a number of tutorial as I try to increase my wisdom in perl. However the one scripts I have come across does not simply start! Everytime it's executed it returns to command line. </p. BTW this is the contents of the employees.txt file
Any help or advice would be greatly welcomed. Thanks! ------------------------------------------------------------------------- Hi all just thought I'd ley you know that I think I got the script to do the following: The purpose of this is to perform the following:Mr John Doe R&D 21000 Miss Gloria Dunne HR 23000 Mr Jack Stevens HR 45000 Mrs Julie Fay R&D 30000 Mr Patrick Reed R&D 33000
I then entered the following at the command screen: ./filename.pl "R&D" which produced this:#!/usr/bin/perl #open the employeesfile open (EMPLOYEES,"employees.txt") or die "Tough: $!\n\n"; #for each line while ($line = <EMPLOYEES>) { #remove the carriage return chomp $line; #split the line between tabs #and get the different elements ($name,$department, $salary) = split /\t/, $line; #go to the next line unless the name starts with "Mr " next unless$name =~ /^Mr /; #go to the next line unless the salary is more than 25000. next unless$salary > 5000; #go to the next line unless the department is R&D. next unless$department eq $ARGV[0]; #since all employees here are male, #remove the particle in front of their name $name =~ s/Mr//; print"$name\n"; print"$department\n"; print"$salary\n"; } close (EMPLOYEES);
|
|---|