Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Use of uninitialized value in print at line 20 (#1)

by GrandFather (Saint)
on Feb 25, 2016 at 06:21 UTC ( [id://1156106]=note: print w/replies, xml ) Need Help??


in reply to Use of uninitialized value in print at line 20 (#1)

The problem is you recurs 1 too many times. However, there is a swathe of smelly areas in your code. Take a look at the following code to see how it can be improved in various ways. You may want to ask questions about why various things have been done or how they work.

use strict; use warnings; use 5.010; my @inputArray = (1, 2, 3, 4, 5, 6, 7, 8); traverseArray(\@inputArray, 0); sub traverseArray { my ($aRef, $index) = @_; return if $index >= @$aRef; print "$aRef->[$index]\n"; traverseArray($aRef, $index + 1); }
Premature optimization is the root of all job security

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found