How do I write this in Perl?

Posted on 2004-11-27
Last Modified: 2010-05-18
Hi . . . I am a rookie Programming Student.  Just starting out.   I'm having trouble with my homework.   My program is working until I have to add some information.  This information is :  Pay Rate for hours > 40 and <= 45 = Time-and-a-half.
                        Pay Rate for hours > 45 = Double-time.

The fields in my file represent Employees Name, Hours worked, Pay Rate, and Gross Pay.
This is what I wrote . . . . .what did I do wrong . . .someone please tell me the correct way to write this!    Thank you!

if ($hoursworked <=40){
$grosspay = $hoursworked * $payrate;

} elsif ($hoursworked >40 and <=45){
$grosspay = $hoursworked * $payrate + 0.5 * $payrate * ($hoursworked - 40)

} elsif ($hoursworked >45){
$grosspay = $hoursworked * $payrate + 2.0 * $payrate * ($hoursworked - 40)
Question by:jmeyer34
    LVL 11

    Accepted Solution

    you missed the variable name in your elsif condition

    it should be

    }elsif($hoursworked > 40 and $hoursworked <= 45){

    and not

    }elsif($hoursworked > 40 and <= 45){  #although this looks ok, it is not :-)

    Have Fun!

    Author Comment

    Thank you very much!!   This is a great site!  It works!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now