Program for perlPerl-Minimum & Maximum valuePerl Script ExplanationPerl confused with scriptAlias for...
Why does the hash of infinity have the digits of π?
What does ${!#} mean in Shell scripting?
Is there a simple example that empirical evidence is misleading?
Count rotary dial pulses in a phone number (including letters)
Why would Ryanair allow me to book this journey through a third party, but not through their own website?
How to reverse input order?
Efficient Algorithm for the boundary of a set of tiles
Defining the standard model of PA so that a space alien could understand
Dad jokes are fun
Is it rude to call a professor by their last name with no prefix in a non-academic setting?
Who is in charge of Wakanda?
Is the field of q-series 'dead'?
Best material to absorb as much light as possible
Is it legal to have an abortion in another state or abroad?
Which European Languages are not Indo-European?
NIntegrate doesn't evaluate
Can I summon an otherworldly creature with the Gate spell without knowing its true name?
Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?
Why did Jon Snow do this immoral act if he is so honorable?
Why isn't 'chemically-strengthened glass' made with potassium carbonate to begin with?
Why most published works in medical imaging try reducing false positives?
Need to read my home electrical meter
Python program to take in two strings and print the larger string
Is the Unsullied name meant to be ironic? How did it come to be?
Program for perl
Perl-Minimum & Maximum valuePerl Script ExplanationPerl confused with scriptAlias for perl scriptPeculiar error in perl Programlinux shell command in Perl programperl library getopts.plInstall program with Perl?BEGIN {…}; in PerlPerl program for unix
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I get an error at the line stating $input =~ s/(^s+|s+$)//g; Could anyone explain whats wrong with it?
the goal of the program is to input 3 numbers that equate to the sides of a triangle. The program checks if the 3 numbers are able to make a triangle (a^2 + b^2 >=< c^2) and then also checks the sides make equilateral or isosceles or scalene. I keep getting this error message as soon as i run it.
"./triangletype.pl Scalar found where operator expected at ./triangletype.pl line 21, near "$input $input" (Missing operator before $input?) syntax error at ./triangletype.pl line 21, near "$input $input " Execution of ./triangletype.pl aborted due to compilation errors."
any help would be appreciated.
'#!/usr/bin/perl'
my $input;
my @triangleSides;
my $triangleLength = 0;
my $isTriangle = 0;
my $rao;
my $same = 0;
my $triType;
while ($triangleLength != 3) {
print "Enter the sides of the trianglen";
$input = <STDIN>;
chomp $input
$input =~ s/(^s+|s+$)//g;
@triangleSides = split(' ', $input);
$triangleLength = scalar @triangleSides;
}
my $a = $triangleSides[0];
my $b = $triangleSides[1];
my $c = $triangleSides[2];
if ($a + $b > $c && $a + $c > $b && $b + $c > $a) {
print "this is a valid trianglen";
$isTriangle = 1;
}else{
print "This is not a valid triangle!n";
exit;
}
if ($isTriangle) {
my $a2 = $a ** 2;
my $b2 = $b ** 2;
my $c2 = $c ** 2;
if ($a2 + $b2 == $c2) {
$rao = "right";
}if ($a2 + $b2 > $c2) {
$rao = "acute";
}if ($a2 + $b2 < $c2) {
$rap = "obtuse";
}
if ($a eq $b) {
$same++;
}if ($a eq $c) {
$same++;
}if ($b eq $c) {
$same++;
}
if ($same == 3) {
$triType = "equilateral";
}if ($same == 2) {
$triType = "isosceles";
}if ($same == 0) {
$triType = "scalene";
}
print "@triangleSides are the sides of a $rao $triType triangles.n";
}
perl
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I get an error at the line stating $input =~ s/(^s+|s+$)//g; Could anyone explain whats wrong with it?
the goal of the program is to input 3 numbers that equate to the sides of a triangle. The program checks if the 3 numbers are able to make a triangle (a^2 + b^2 >=< c^2) and then also checks the sides make equilateral or isosceles or scalene. I keep getting this error message as soon as i run it.
"./triangletype.pl Scalar found where operator expected at ./triangletype.pl line 21, near "$input $input" (Missing operator before $input?) syntax error at ./triangletype.pl line 21, near "$input $input " Execution of ./triangletype.pl aborted due to compilation errors."
any help would be appreciated.
'#!/usr/bin/perl'
my $input;
my @triangleSides;
my $triangleLength = 0;
my $isTriangle = 0;
my $rao;
my $same = 0;
my $triType;
while ($triangleLength != 3) {
print "Enter the sides of the trianglen";
$input = <STDIN>;
chomp $input
$input =~ s/(^s+|s+$)//g;
@triangleSides = split(' ', $input);
$triangleLength = scalar @triangleSides;
}
my $a = $triangleSides[0];
my $b = $triangleSides[1];
my $c = $triangleSides[2];
if ($a + $b > $c && $a + $c > $b && $b + $c > $a) {
print "this is a valid trianglen";
$isTriangle = 1;
}else{
print "This is not a valid triangle!n";
exit;
}
if ($isTriangle) {
my $a2 = $a ** 2;
my $b2 = $b ** 2;
my $c2 = $c ** 2;
if ($a2 + $b2 == $c2) {
$rao = "right";
}if ($a2 + $b2 > $c2) {
$rao = "acute";
}if ($a2 + $b2 < $c2) {
$rap = "obtuse";
}
if ($a eq $b) {
$same++;
}if ($a eq $c) {
$same++;
}if ($b eq $c) {
$same++;
}
if ($same == 3) {
$triType = "equilateral";
}if ($same == 2) {
$triType = "isosceles";
}if ($same == 0) {
$triType = "scalene";
}
print "@triangleSides are the sides of a $rao $triType triangles.n";
}
perl
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
You are missing a semicolon afterchomp $input. There may be other errors.
– steeldriver
40 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago
add a comment |
I get an error at the line stating $input =~ s/(^s+|s+$)//g; Could anyone explain whats wrong with it?
the goal of the program is to input 3 numbers that equate to the sides of a triangle. The program checks if the 3 numbers are able to make a triangle (a^2 + b^2 >=< c^2) and then also checks the sides make equilateral or isosceles or scalene. I keep getting this error message as soon as i run it.
"./triangletype.pl Scalar found where operator expected at ./triangletype.pl line 21, near "$input $input" (Missing operator before $input?) syntax error at ./triangletype.pl line 21, near "$input $input " Execution of ./triangletype.pl aborted due to compilation errors."
any help would be appreciated.
'#!/usr/bin/perl'
my $input;
my @triangleSides;
my $triangleLength = 0;
my $isTriangle = 0;
my $rao;
my $same = 0;
my $triType;
while ($triangleLength != 3) {
print "Enter the sides of the trianglen";
$input = <STDIN>;
chomp $input
$input =~ s/(^s+|s+$)//g;
@triangleSides = split(' ', $input);
$triangleLength = scalar @triangleSides;
}
my $a = $triangleSides[0];
my $b = $triangleSides[1];
my $c = $triangleSides[2];
if ($a + $b > $c && $a + $c > $b && $b + $c > $a) {
print "this is a valid trianglen";
$isTriangle = 1;
}else{
print "This is not a valid triangle!n";
exit;
}
if ($isTriangle) {
my $a2 = $a ** 2;
my $b2 = $b ** 2;
my $c2 = $c ** 2;
if ($a2 + $b2 == $c2) {
$rao = "right";
}if ($a2 + $b2 > $c2) {
$rao = "acute";
}if ($a2 + $b2 < $c2) {
$rap = "obtuse";
}
if ($a eq $b) {
$same++;
}if ($a eq $c) {
$same++;
}if ($b eq $c) {
$same++;
}
if ($same == 3) {
$triType = "equilateral";
}if ($same == 2) {
$triType = "isosceles";
}if ($same == 0) {
$triType = "scalene";
}
print "@triangleSides are the sides of a $rao $triType triangles.n";
}
perl
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I get an error at the line stating $input =~ s/(^s+|s+$)//g; Could anyone explain whats wrong with it?
the goal of the program is to input 3 numbers that equate to the sides of a triangle. The program checks if the 3 numbers are able to make a triangle (a^2 + b^2 >=< c^2) and then also checks the sides make equilateral or isosceles or scalene. I keep getting this error message as soon as i run it.
"./triangletype.pl Scalar found where operator expected at ./triangletype.pl line 21, near "$input $input" (Missing operator before $input?) syntax error at ./triangletype.pl line 21, near "$input $input " Execution of ./triangletype.pl aborted due to compilation errors."
any help would be appreciated.
'#!/usr/bin/perl'
my $input;
my @triangleSides;
my $triangleLength = 0;
my $isTriangle = 0;
my $rao;
my $same = 0;
my $triType;
while ($triangleLength != 3) {
print "Enter the sides of the trianglen";
$input = <STDIN>;
chomp $input
$input =~ s/(^s+|s+$)//g;
@triangleSides = split(' ', $input);
$triangleLength = scalar @triangleSides;
}
my $a = $triangleSides[0];
my $b = $triangleSides[1];
my $c = $triangleSides[2];
if ($a + $b > $c && $a + $c > $b && $b + $c > $a) {
print "this is a valid trianglen";
$isTriangle = 1;
}else{
print "This is not a valid triangle!n";
exit;
}
if ($isTriangle) {
my $a2 = $a ** 2;
my $b2 = $b ** 2;
my $c2 = $c ** 2;
if ($a2 + $b2 == $c2) {
$rao = "right";
}if ($a2 + $b2 > $c2) {
$rao = "acute";
}if ($a2 + $b2 < $c2) {
$rap = "obtuse";
}
if ($a eq $b) {
$same++;
}if ($a eq $c) {
$same++;
}if ($b eq $c) {
$same++;
}
if ($same == 3) {
$triType = "equilateral";
}if ($same == 2) {
$triType = "isosceles";
}if ($same == 0) {
$triType = "scalene";
}
print "@triangleSides are the sides of a $rao $triType triangles.n";
}
perl
perl
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 52 mins ago
Hank Hank
1
1
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
You are missing a semicolon afterchomp $input. There may be other errors.
– steeldriver
40 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago
add a comment |
1
You are missing a semicolon afterchomp $input. There may be other errors.
– steeldriver
40 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago
1
1
You are missing a semicolon after
chomp $input. There may be other errors.– steeldriver
40 mins ago
You are missing a semicolon after
chomp $input. There may be other errors.– steeldriver
40 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Hank is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f520760%2fprogram-for-perl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hank is a new contributor. Be nice, and check out our Code of Conduct.
Hank is a new contributor. Be nice, and check out our Code of Conduct.
Hank is a new contributor. Be nice, and check out our Code of Conduct.
Hank is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f520760%2fprogram-for-perl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You are missing a semicolon after
chomp $input. There may be other errors.– steeldriver
40 mins ago
steeldriver you are an angel idk how i missed that thank you so much. It's been a long day. Works perfectly now!
– Hank
29 mins ago