PERL as ruby

Ruby code posted by p@r
created at 23 Jul 14:28, updated at 09 Aug 14:46

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w

use strict;
use DBI;

use Private::Module::SQL;
use Time::HiRes qw( gettimeofday tv_interval);

my $dbh = Private::Module::SQL->connect;

my @ids;
push @ids,int(rand(60000)) for (1..20);

my @rand;
push @rand,int(rand(10)) for (1..(scalar @ids));

my $t0 = [gettimeofday];

my $sth = $dbh->prepare("insert into counts (`id`, `count`) values (?,?)");
my $tuples = $sth->execute_array(undef, \@ids, \@rand);
  if ($tuples) {
      print "Successfully inserted $tuples records\n";
  }

print tv_interval ($t0) . "sec\n";



# why have 100 pages if i can't search them?
613 Bytes in 3 ms with coderay