my @names = getid( 'foo1', 'bar1', [] ); # first run while ( 1 ) { # WARNING: endless loop @names = getid( 'fooX', 'barX', \@names ); # call with last result }