Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^7: loop problem

by poj (Abbot)
on Jun 12, 2018 at 18:05 UTC ( [id://1216496]=note: print w/replies, xml ) Need Help??


in reply to Re^6: loop problem
in thread loop problem

Declare the variables outside the subroutine

#!/usr/bin/env perl use strict; use warnings; use utf8; use feature "say"; use Math::Trig; my ($radius,$c); sub intro { say "What is the radius?"; $radius = <STDIN>; chomp ($radius); my $a = 2*pi; $c = $radius * $a } intro(); if ($radius==0) { say "circumference= ", $radius; } elsif ($radius<0) { say "Radius should be greater than 0"; intro(); } else { say "circumference= ", $c }
poj

Replies are listed 'Best First'.
Re^8: loop problem
by stevieb (Canon) on Jun 12, 2018 at 18:14 UTC

    Ahhh, now I understand. D'oh! :D

    Note the missing semi-colon on one of the last lines there...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216496]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-23 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found