小编mad*_*dia的帖子

为什么Tcler建议支持你的`expr`essions?

我们可以用两种可能的方式来评估这两个表达式:

   set a 1
   set b 1
   puts [expr $a + $b ]
   puts [expr {$a + $b } ]
Run Code Online (Sandbox Code Playgroud)

但是为什么第一个讨厌有经验的Tclers,并认为这是不好的做法?第一次使用是否expr有一些安全问题?

tcl

11
推荐指数
2
解决办法
1043
查看次数

如何使用sequelize获取行的明确值?

我有价值的桌子

id country 
1  india
2  usa
3  india
Run Code Online (Sandbox Code Playgroud)

我需要使用sequelize.js从country列中找到不同的值

这是我的示例代码......

Project.findAll({

    attributes: ['country'],
    distinct: true
}).then(function(country) {
     ...............
});
Run Code Online (Sandbox Code Playgroud)

有没有办法找到distict值

node.js express sequelize.js

8
推荐指数
3
解决办法
2万
查看次数

静态检测Tcl脚本中的错误

我已经开发了一些代码,我在Linux机器上遇到了错误标记Tcl解释器的问题.

#!/usr/bin/tclsh
if {1} {
  puts "abc1"
} elseif {} {
  puts "abc2" 
}
Run Code Online (Sandbox Code Playgroud)

上述代码在"elseif"进入条件之前不会标记条件 错误elseif.有没有办法检查这种无意中完成的拼写错误.

tcl

6
推荐指数
2
解决办法
3076
查看次数

检查机器中安装的模块列表

我已经制作了一个脚本来管理管理员需要在机器上安装的模块列表.

我试图通过下面的代码检查安装的模块.奇怪的是它在机器中显示甚至安装的模块not installed

    #!/usr/bin/perl -w
    my @module_list =('Smart::Comments','HTML::Parse');
    foreach (@module_list) {
      eval { require "$_" };
      if (!($@)) {
        print "Module Not installed : $_\n";
      }
    }
Run Code Online (Sandbox Code Playgroud)

perl module

5
推荐指数
1
解决办法
348
查看次数

使用require访问全局变量的值?

是否可以使用require在另一个perl脚本中访问声明的全局变量的值?

例如。

Config.pl

#!/usr/bin/perl
use warnings;
use strict;

our $test = "stackoverflow"
Run Code Online (Sandbox Code Playgroud)

Main.pl

#!/usr/bin/perl
use warnings;
use stricts;

require "Config.pl"

print "$test\n";
print "$config::test\n";
Run Code Online (Sandbox Code Playgroud)

perl

5
推荐指数
1
解决办法
1465
查看次数

cpan模块的目录结构

我正在研究我想在CPAN中提交的perl模块.但是我对模块的目录结构有一个小查询.

根据perlmonk文章,模块代码目录结构应如下所示:

    Foo-Bar-0.01/Bar.pm
    Foo-Bar-0.01/Makefile.PL
    Foo-Bar-0.01/MANIFEST
    Foo-Bar-0.01/Changes
    Foo-Bar-0.01/test.pl
    Foo-Bar-0.01/README
Run Code Online (Sandbox Code Playgroud)

但是当我使用该命令时,结构生成如下

    h2xs -AX Foo::Bar

    Writing Foo-Bar/lib/Foo/Bar.pm
    Writing Foo-Bar/Makefile.PL
    Writing Foo-Bar/README0
    Writing Foo-Bar/t/Foo-Bar.t
    Writing Foo-Bar/Changes
    Writing Foo-Bar/MANIFEST
Run Code Online (Sandbox Code Playgroud)

perl cpan

5
推荐指数
1
解决办法
476
查看次数

出现错误“错误:超过 2000 毫秒超时。对于异步测试和挂钩,请确保调用了“完成()”;”

我看到以下测试用例的使用mochachai库。 Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

这是code用于测试 amazon lambda 函数的处理程序。(目前,我没有使用super-testnpm 模块)

const expect = require('chai').expect;
const mongoose = require('mongoose');
const CONFIG_DEV_MONGODB = require('../../config/config.dev').DB_CONNECTION_URL;


describe('get the foo', () => {

    let handler;
    before(() => {

        process.env.DEPLOYMENT_STAGE = 'test';
        process.env.DB_CONNECTION_URL = CONFIG_DEV_MONGODB;
        handler = require('./get');
    });

    after(() => {

        if (mongoose.connection) {
            mongoose.connection.close();
        }
    });

    it('validate getFeaturedProducts get …
Run Code Online (Sandbox Code Playgroud)

mocha.js node.js chai

4
推荐指数
2
解决办法
1万
查看次数

检查perl中子例程中传递的变量类型

我想得到传递给子程序的变量类型.虽然谷歌搜索我遇到了下面的解决方案,但这没有给出满意的结果.我的问题在下面的例子中说明

    sample("test");
    sample(\%a);

    sub sample {
      my ($argv1) = @_;
      if(ref($argv1) eq "STRING") {
        print "string\n";
      }
      elsif(ref($argv1) eq "HASH") {
        print "HASH\n";
      }

    }
Run Code Online (Sandbox Code Playgroud)

perl subroutine

3
推荐指数
1
解决办法
5766
查看次数

perl中的函数原型

我正在尝试使用内置推送功能的类似功能创建子程序mypush,但下面的代码无法正常工作.

    @planets = ('mercury', 'venus', 'earth', 'mars');
    myPush(@planets,"Test");

    sub myPush (\@@) {
         my $ref = shift;
         my @bal = @_;
         print "\@bal :  @bal\nRef : @{$ref}\n";
         #...
    } 
Run Code Online (Sandbox Code Playgroud)

perl subroutine subroutine-prototypes

3
推荐指数
1
解决办法
486
查看次数

在SQL*Plus中声明绑定变量

我正在使用SQL*Plus.当我使用以下查询时,它给出错误

Error report:
ORA-06550: line 4, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
Run Code Online (Sandbox Code Playgroud)

询问

declare 
id varchar2(80) :='test123'; 
begin
select test_quote,test_id from order_link where id = 'test123';
end;
Run Code Online (Sandbox Code Playgroud)

oracle sqlplus

3
推荐指数
1
解决办法
5万
查看次数