Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

help

Name: Anonymous 2011-04-04 7:42

print "please enter the retail price ";
$retailPrice=<STDIN>;
print "Please enter the transaction code ";
$transCode=<STDIN>;
chomp $transCode;
print "Please enter employee number ";
$empNum=<STDIN>;
if ($transCode eq "S")
{
$comm=$retailPrice*.05
}
else
{
if ($transCode eq "M")
{
$comm=$retailPrice*.07
}
else
{
if (transCode eq "L")
{
$comm=$retailPrice*.10
} #end if ($transCode eq "M")
} #end if ($transCode eq "M")
} #end if ($transCode eq "S")
print "Retail price is ". $retailPrice;
print "Commision is ". $comm;
print "Employee number is ". $empNum;

Name: Anonymous 2011-04-04 7:43

sorry i dont now how i left the question out

Ok so im learning pearl as part of my sys admin diploma and this is like 4th attempt at making something. What I want to know is why do the last 2 lines print along the same line but the third from last line prints on its own.

Name: Anonymous 2011-04-04 8:16

pearl

Name: Anonymous 2011-04-04 9:36

FIOC
[code]
Then ask again.

Name: Anonymous 2011-04-04 10:04

I'm not even going to bother.

Name: Anonymous 2011-04-04 11:05

Because you're not chomping $retailPrice. Now please leave forever. Or at least lurk a few years before posting next.

Name: Anonymous 2011-04-04 11:20

sys admin diploma

Oh dear Raptor Jesus I lol'd.

Been a sysadmin for 12 years and there ain't nothing they gonna teach you in a class that applies to real work. No Thing.
Hell, they didn't even teach you how to spell PERL.

Sorry >>4-kun, FOIC is the scourge of the Earth and is not necessary for anything except wiping ones ass with.

Name: Anonymous 2011-04-04 11:51

Raptor Jesus
FOIC
mailto:noko

Name: lol 2011-04-04 12:24

back again, dont worry i fixed it.

print "please enter the retail price ";
$retailPrice=<STDIN>;
print "Please enter the transaction code ";
$transCode=<STDIN>;
chomp $transCode;
print "Please enter employee number ";
$empNum=<STDIN>;
if ($transCode eq "S" or $transCode eq "s" or $transCode eq "M" or $transCode eq "m" or $transCode eq "L" or $transCode eq "l")
{
    if ($transCode eq "S" or $transCode eq "s")
    {
        $comm=$retailPrice*.05
    }
    else
        {
            if ($transCode eq "M" or $transCode eq "m")
        {
            $comm=$retailPrice*.07
        }
        else
        {
            if ($transCode eq "L" or $transCode eq "l")
            {
                $comm=$retailPrice*.10
            } #end if ($transCode eq "L" or $transCode eq "l")
        } #end if ($transCode eq "M" or $transCode eq "m")
    } #end if ($transCode eq "S" or $transCode eq "s")
        print "Retail price is ". $retailPrice;
    print "Commision is ". $comm. "\n";
    print "Employee number is ". $empNum. "\n";
}
else
{
    print "Invalid code"
} # end if  ($transCode eq "S" or $transCode eq "s" or $transCode eq "M" or $transCode eq "m" or $transCode eq "L" or $transCode eq "l")

Name: Anonymous 2011-04-04 12:26

ONE WORD, THE FORCING OF THE INDENTED CODE. THREAD OVER.

Name: nambla_dot_org_rules_you 2011-04-04 12:47

Or the OP could commit ritual suicide.

Name: Anonymous 2011-04-04 12:50

Perl? Looks more like PHP to me. Now I finally realize why Perl is such a shitty language.

Name: Anonymous 2011-04-04 12:57

ONE WORD: THE LACK OF INDENTED CODE. THREAD OVER.

Name: Anonymous 2011-04-04 13:00

op here
that was my fix above BTW, i only started learning perl 4 weeks ago and i have never tried any language before. im well aware that there is probably better languages out there but this is the one the lecturers at my uni thought they should start us on.

i'm also more than aware that there are shorter ways to do this (elsif) but the way it is written was how i was a instructed to write it. it is ofcourse my fault for not including the brief given to us but in the end all i ask was why the last to print statements are on the same line.

Name: Anonymous 2011-04-04 13:03

>>14
I helped you (>>6) and told you to get lost. One last word for the road: elsif. I don't know what disgusts me more, your stupidity and inability to read the documentation, or me helping you.

Name: Anonymous 2011-04-04 13:29

>>15
You postinghelping once in this thread is already way disgusting, but coming back for more is simply awful.

Name: Anonymous 2011-04-04 13:35

how i was a instructed to write it.
Tool. If you can't convince your clients that there clearly is a better way, you are worthless.

Name: Anonymous 2011-04-04 13:36

Name: Anonymous 2011-04-04 13:38

>>18
I am aware of that term. Why did you post that?

Name: Anonymous 2011-04-04 14:46

Use [code].
Use gramemar.

Name: Anonymous 2011-04-04 15:24

use strict;

Name: Anonymous 2011-04-04 22:02

It was not a client it was my teacher, she knows there is a better way and asked us to concentrait on writting the script this way as we had only just started using perl the pervious week. The 2 weeks before that we were learning about diffrent types of logic and the diffrence between programing and maths

Umm im a student not a code monkey.

Use strict; makes it fail on almost every line and i really have no idea why. I'm going to try and figure that one out soon. I'll try and find the faq that im pretty sure i should've read before posting.

WTF Is forced indenting anyway?

Name: Anonymous 2011-04-04 22:36

>>22
WTF Is forced indenting anyway?
I like you.

Name: Anonymous 2011-04-04 22:44

>>1
I, the author of ``Perl: A step further paint programming'', ``Perl: The Ascii Art Programming Language'', ``Perl and cryptographic-oriented programming'', and my last book ``Perl 6: Operating in the operator's operators language'', am ashamed by reading such code.

Your Perl code is not idiomatic, you're using long, meaningful variable names, using <STDIN> instead of the shorter <>, and, most important, you're not using the $_ implicit variable!! I quite like, though, your decision of not using any indentation whatsoever, but it could be better, and can be shortened to a one-liner by inflating the if-elses to ?:s.

Name: Anonymous 2011-04-05 4:34

>>22
You're either not OP or you were trolling all along.

Name: Anonymous 2011-04-05 6:25

Use strict; makes it fail on almost every line and i really have no idea why.
BECAUSE YOU FUCKING SUCK AT WRITING STANDARDS-CONFORMING PERL CODE WHY DON'T YOU READ THE ERRORS AND FIX YOUR GODDAMN MISTAKES

Don't change these.
Name: Email:
Entire Thread Thread List