在Linux的我的主文件夹中,我有几个配置文件,其中"rc"作为文件扩展名:
$ ls -a ~/|pcregrep 'rc$'
.bashrc
.octaverc
.perltidyrc
.screenrc
.vimrc
Run Code Online (Sandbox Code Playgroud)
这些名称中的"rc"是什么意思?
我仔细阅读了JSON描述http://json.org/,但我不确定我是否知道这个简单问题的答案.哪些字符串是最小可能的有效JSON?
"string" 字符串是有效的JSON吗?42 是简单的数字有效JSON?true 布尔值是有效的JSON吗?{} 空对象是有效的JSON吗?[] 空数组是一个有效的JSON吗?以下是在JavaScript中将日期序列化为ISO 8601字符串的标准方法:
var now = new Date();
console.log( now.toISOString() );
// outputs '2015-12-02T21:45:22.279Z'
Run Code Online (Sandbox Code Playgroud)
我需要相同的输出,但没有毫秒.我怎么输出2015-12-02T21:45:22Z?
我svn:external在我的存储库中创建了一个.一切正常,除了svn status命令的输出.在输出中有很多我不需要的信息:
$ svn st
X lib
Performing status on external item at 'lib'
Run Code Online (Sandbox Code Playgroud)
我可以运行svn st --ignore-externals -q,我可以将这一行放在一个小脚本中,但也许有更好的解决方案.如何在不查看外部信息的情况下查看工作副本的状态?
找到MySQL变量值是一项简单的任务:
mysql> show variables where Variable_name = 'version'; +---------------+--------------------+ | Variable_name | Value | +---------------+--------------------+ | version | 5.0.19-Max | +---------------+--------------------+ 1 row in set (0.00 sec)
但是有没有任何语法允许只选择具有变量值的列,如下所示:
mysql> command_i_want_to_know +--------------------+ | Value | +--------------------+ | 5.0.19-Max | +--------------------+ 1 row in set (0.00 sec)
在perlvar文档中有一个文本@_:
在子例程中,数组@_包含传递给该子例程的参数.在子程序中,@ _是数组运算符push,pop,shift和unshift的默认数组.
这是一种使用shift不带参数从数组中获取第一个元素的常用方法.它经常被用作:
sub some_method {
my $self = shift; # the same as `my $self = shift @_;`
...
}
Run Code Online (Sandbox Code Playgroud)
但是在文档中写道它可以与之一起使用push,但是如果没有明确指定@_push ,我就无法创建工作示例.从阅读这篇文章我期待push 123;推动@_,但它不起作用.
这是一个perl脚本:
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
my @numbers = qw(
0.254
0.255
0.256
);
foreach my $number (@numbers) {
my $rounded = sprintf '%.2f', $number;
say "$number => $rounded";
}
foreach my $number (@numbers) {
$number += 100;
my $rounded = sprintf '%.2f', $number;
say "$number => $rounded";
}
Run Code Online (Sandbox Code Playgroud)
它输出:
0.254 => 0.25
0.255 => 0.26
0.256 => 0.26
100.254 => 100.25
100.255 => 100.25
100.256 => 100.26
Run Code Online (Sandbox Code Playgroud)
对我来说,Perl与舍入不一致是很奇怪的.我希望以.255结尾的两个数字都被舍入为.26这对于0.255是正确的,但对于数字100.255它是错误的
以下是Perl Cookbook的报价http://docstore.mik.ua/orelly/perl/cookbook/ch02_04.htm
sprintf.f格式允许您指定特定数量的小数位以将其参数舍入到.Perl查看下面的数字,如果它是5或更大,则向上舍入,否则向下舍入.
但我在http://perldoc.perl.org/functions/sprintf.html中看不到任何证据证明它是正确的
这是sprintf或Perl …
有一种观点认为,在vim中工作时,不应使用Esc键(改为使用ctrl + c),也不要在键盘上使用箭头键(使用h,j,k,l).但是很难不使用这些键.我认为有一种方法可以在.vimrc中禁用这些键,所以除了使用ctrl + c和hjkl之外别无选择.
我搜索了一下,在这个链接上找到了解决方案.所以我在.vimrc文件中插入了以下内容:
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
inoremap <Esc> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
noremap <Esc> <NOP>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.将此添加到我的.vimrc会破坏我对功能键的映射.另一个问题是它不会阻止箭头键的功能,而是当我在正常模式下按下Down时,会执行多个动作 - 光标向上移动一行,创建新行并插入字符"B".
如何在我的vim 7.2中禁用光标键和Esc键而不破坏其他任何内容?
这是一个例子.我正在创建一个名为的目录-,但我无法cd进入它.该命令将cd -我返回到上一个目录.我有点沮丧,cd "-"以同样的方式工作.我可以使用完整路径进入该目录~/-,但还有其他方法吗?
user@server:~$ cd /tmp
user@server:/tmp$ cd
user@server:~$ mkdir -
user@server:~$ cd -
/tmp
user@server:/tmp$ cd
user@server:~$ cd "-"
/tmp
user@server:/tmp$ cd ~/-
user@server:~/-$
Run Code Online (Sandbox Code Playgroud) 这是我不明白的事情.
此脚本正常工作(注意地图功能中的连接):
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %aa = map { 'a' . '' => 1 } (1..3);
print Dumper \%aa;
__END__
output:
$VAR1 = {
'a' => 1
};
Run Code Online (Sandbox Code Playgroud)
但是没有连接,地图就不起作用了.这是我希望工作的脚本,但它没有:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %aa = map { 'a' => 1 } (1..3);
print Dumper \%aa;
__END__
output:
Not enough arguments for map at e.pl line 7, near "} ("
syntax error at e.pl line 7, near "} ("
Global symbol "%aa" …Run Code Online (Sandbox Code Playgroud)