Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Just another Perl shrine
 
PerlMonks  

Re: subroutine recurse vs goto LABEL

by patgas (Friar)
on Sep 14, 2001 at 18:39 UTC ( [id://112490]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to subroutine recurse vs goto LABEL

Using a recursive function will always eat up more memory as you go, especially since your functions never stop or return anything. I suppose out your two examples, the second one is better, just because it's not recursive. Not that you asked, but I think you could write it more clearly and elegantly like this:

#!/usr/bin/perl -w use strict; while ( <STDIN> ) { chomp(); if ( /^\d+$/ ) { print "You entered: $_\n"; } else { print "Not a number!\n"; } }

"We're experiencing some Godzilla-related turbulence..."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://112490]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.