dbgen.pl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/perl
  2. $size = shift;
  3. if ($size eq "")
  4. {
  5. die "usage: dbgen.pl [size]\n";
  6. }
  7. @firstnames = ("Al", "Bob", "Charles", "David", "Egon", "Farbood",
  8. "George", "Hank", "Inki", "James");
  9. @lastnames = ("Aranow", "Barker", "Corsetti", "Dershowitz", "Engleman",
  10. "Franklin", "Grice", "Haverford", "Ilvedson", "Jones");
  11. @states = ("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
  12. "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
  13. "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
  14. "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
  15. "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
  16. print "<?xml version=\"1.0\"?>\n";
  17. print "\n";
  18. print "<table>\n";
  19. for ($i=0; $i<$size; $i++)
  20. {
  21. $first = $firstnames [$i % 10];
  22. $last = $lastnames [($i / 10) % 10];
  23. $state = $states [($i / 100) % 50];
  24. $zip = 22000 + $i / 5000;
  25. printf " <row>\n";
  26. printf " <id>%04d</id>\n", $i;
  27. printf " <firstname>$first</firstname>\n", $i;
  28. printf " <lastname>$last</lastname>\n", $i;
  29. printf " <street>%d Any St.</street>\n", ($i % 100) + 1;
  30. printf " <city>Anytown</city>\n";
  31. printf " <state>$state</state>\n";
  32. printf " <zip>%d</zip>\n", $zip;
  33. printf " </row>\n";
  34. }
  35. print "</table>\n";