Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

RE: TLD generator

by lhoward (Vicar)
on Jul 17, 2000 at 07:05 UTC ( #22814=note: print w/replies, xml ) Need Help??

in reply to TLD generator

The code above generates duplicates (i.e. the same TLD will be generated more than once). Consider:
The following does not have the duplicates problem. It could be optimized a bit (and shortened too), but I leave that as an exercise to the reader...
#!/usr/bin/perl -w use strict; my @chars=(('a'..'z'),(0..9)); tld('',$_) for (3..6); sub tld{ my ($txt,$cnt)=@_; if($cnt==0){ print "$txt\n"; }else{ tld($txt.$_,$cnt-1) for (@chars); } }

Replies are listed 'Best First'.
RE: RE: TLD generator
by vkonovalov (Monk) on Jul 17, 2000 at 12:03 UTC
    Agreed. Recursion suggests itself in this case.
    And much better - is to get rid of digits and then just use strings increment. So it will be just
    That's all :)
      now your missing numbered TLD's though :)

      /****************************/, /*****************************/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://22814]
[usemodperl]: yes, in script too, problem is find_modules but only in a script
[usemodperl]: one liner works, nothing from script, weird
[usemodperl]: i even tried to run perl again from inside script with qx and the working one liner: nada

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2018-06-23 12:08 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.