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:
Anonymous2011-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.
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.
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")
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.
>>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.
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.
>>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.
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