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

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
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:
1. Identifies the name, department and salary of the employee
2. Ignores and goes to the next line if the employee is female (the name does not start with Mr)
3. Ignores and goes to the next line if the salary is less or equal to 25000.
4. Ignores and goes to the next line if the department is not "R&D".
5. Prints the name and the salary of the employee on the screen.
By using the following code
#!/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);
I then entered the following at the command screen: ./filename.pl "R&D" which produced this:
John Doe R&D 21000 Patrick Reed R&D 33000 Thanks for your help and advice!! :)

In reply to Reading from filehandles in a loop and matching lines by Nathan_84

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.