Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: recursive call of current script

by tybalt89 (Monsignor)
on Jun 22, 2022 at 01:50 UTC ( [id://11144928]=note: print w/replies, xml ) Need Help??


in reply to recursive call of current script

Just wrap in a queue where you can add more things to the front. It does mean you will have to split some things into two parts, but still is just a fairly simple change.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11144894 use warnings; my @functionqueue = @ARGV ? @ARGV : qw( test1 test2 test1 ); # FIXME while( @functionqueue ) { for ( shift @functionqueue ) { /test1/ && do { print "test1 stuff\n"; }; /test2/ && do { print "test2 stuff\n"; unshift @functionqueue, qw( test1 secondpartof2 ); }; /secondpartof2/ && do { print "secondpartof2 stuff\n"; }; } }

Outputs:

test1 stuff test2 stuff test1 stuff secondpartof2 stuff test1 stuff

Log In?
Username:
Password:

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

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

    No recent polls found