Advertisement
Guest User

perl6 to many clients

a guest
Apr 18th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.66 KB | None | 0 0
  1. ## Class
  2.  
  3. class Database {
  4.  
  5.   method connect  {
  6.     my $pg = DB::Pg.new(conninfo => 'host=localhost port=5432 dbname=postgres user=bla password=sadsa');
  7.     return $pg if $pg;
  8.     return -1;
  9.   }
  10.  
  11.   method addDomain ($fqdn, $tld, $sid) {
  12.       my $pg = $.connect;
  13.       $pg.query('insert into public.sourcelist_domain (sid, tld, fqdn)
  14.                   values ($1,$2,$3)', $sid, $tld, $fqdn);
  15.   }
  16. }
  17.  
  18.  
  19. ####  calling function
  20.  
  21. # .. some other stuff goes here
  22.  
  23. my $id = $db.getSourceID("fooBar");
  24. race for $path.IO.lines(:batch(1))  {
  25.        next if / ^\# /;
  26.        my $tld = (.split( / \. / ))[ *-1 ];
  27.        $db.addDomain( $_, $tld, $id);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement