#!/usr/bin/env perl
+use 5.28.0;
use warnings; use strict;
use Syntax::Keyword::Try;
use Benchmark;
* Load and ~/.config/this_script_name.cnf
**/
<<<FILE $0>>>
-
-
);
try{
$stSelHistCNT_CMD->execute($next[0], $next[1]);
my @r = $stSelHistCNT_CMD->fetchrow_array();
if(@r){
- print "Has entry[$next[1]]:".CNFSQL::_decodeQuotes($next[0])
+ say "Has entry[$next[1]]:".CNFSQL::_decodeQuotes($next[0])
}else{
$stSelHistCMD ->execute($next[1]);
@r = $stSelHistCMD->fetchrow_array();
print "\nID`\tDATE`\t Command\t `Count`Host`LenOfCMD~\n";
while (my @next=$pstRows->fetchrow_array()){
$selects++;
- print $cnf->SQL()->CNFSQL::_decodeQuotes( join("` ", @next)),"~\n"
+ print CNFSQL::_decodeQuotes( join("` ", @next)),"~\n"
}
$test->evaluate("5==\$selects",5,$selects);
- $test
#
$test->done();
#
<<selLongest5CMDs<SQL>
SELECT *, LENGTH("CMD") as len FROM public.cmd_history
ORDER BY len DESC LIMIT 5;
->>
\ No newline at end of file
+>>
use Config;
$Config{useithreads} or
die('Recompile Perl with threads to run this program.');
-
use lib::relative "../system/modules";
require CNFParser;
-
-# use lib "system/modules";
-
require TestManager;
my $test = TestManager->new($0)->unsuited();
my $cnf;
use threads::shared;
our $global :shared = 1;
-
try {
+
if ( not $cnf = CNFParser->blank( { DEBUG => 1 } ) ) {
$test->failed("new instance");
}
else {
$test->passed("Passed new instance CNFParser.");
- }
-
-
-
+ }
- my $thr = threads->create('sub1', 'argument');
+ my $thr = threads->create('sub1', 'argument');
+ if ( $thr->is_running() ) {
+ sleep(1);
+ print "Thread $thr running!\n";
+ }
+ else {
+ print "Not running\n";
+ }
my $result1 = threads->create(sub {
my $foo = 50; sleep(.5);
- while ( $foo-- ) {print "first async\n"; yield(); lock($global); $global--; }
+ while ( $foo-- ) { #print "first async\n";
+ yield(); lock($global); $global--; }
yield();
$foo = 150;
- while ( $foo-- ) { print "first async2\n"; yield()}
+ while ( $foo-- ) { #print "first async2\n";
+ yield()}
return [$global];
});
my $result2 = async {
lock($global);
my $foo = 50; sleep(.5);
- while ( $foo-- ) { print "second async\n"; $global++; yield()}
+ while ( $foo-- ) { #print "second async\n";
+ $global++; yield()}
yield();
$foo = 50;
- while ( $foo-- ) { print "second async2\n" }
+ while ( $foo-- ) { #print "second async2\n"
+ }
return [$global];
};
- if ( $thr->is_running() ) {
- sleep(1);
- print "Thread $thr running!\n";
- }
- else {
- print "Not running\n";
- }
+
sleep(2);
print "Thread2 returned [". join (",", @$result2)."]\n";
print "Thread3 returned [". join (",", @$result3)."]\n";
+
+
+
#
$test->done();
#
lock($global);
$glob = $global
}
- while ( $foo-- ) { print "sub1\n"; $global++; yield();sleep(.5)}
+ while ( $foo-- ) { #print "sub1\n";
+ $global++; yield();sleep(.5)}
return ["sub1", $glob, $global];
}