Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Program Not Printing Help

by Athanasius (Archbishop)
on May 16, 2014 at 16:47 UTC ( [id://1086358]=note: print w/replies, xml ) Need Help??


in reply to Program Not Printing Help

Hello Hrand, and welcome to the Monastery!

First: always begin your script with:

use strict; use warnings;

as this will help you identify typos and other syntax errors.

Second, you cannot pass subroutine arguments in Perl as you do in C/C++. You need something like:

sub isPalindrome { my $orig = shift; my $reversed = 0; my $n = $orig; ...

Third, there is a logic error in the second for loop: the first occurrence of the line:

$temp++;

should be deleted.

There are various other observations that could be made as to style, such as preferring for my $i (0 .. $testCases - 1) to the C-style loop used, but the points above are the main ones to start with.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found