我在Git中忘记了我的密码.我该如何重置?我在Stack Overflow上找到了两个解决方案,但我想知道要重置它或获取它的步骤.
我正在尝试将表格的格式从一个OpenOffice Writer文件复制到另一个...我可以告诉我,我正在将样式的名称写入第二个文档,而不是样式数据.
我怀疑这与'styles'
部分内容有关odfContainer
,但我不清楚如何将其写入第二个文档,特别是因为当我$style
在调试器中检查对象时,它看起来与$doc
对象相同,据说装了这个'content'
部分.
这是我到目前为止所得到的......
#! /usr/bin/perl
use warnings;
use strict;
use OpenOffice::OODoc;
my $file='mytest.odt';
my $outfile='doc2.odt';
# load input file
my $container = odfContainer("$file");
$container->raw_export("styles.xml");
my $doc = odfDocument
(
container => $container,
part => 'content'
);
my $style = odfDocument
(
container => $container,
part => 'styles'
);
# load output file
my $container2 = odfContainer( $outfile, create => 'text' );
$container2->raw_import("styles.xml");
my $doc2 = odfDocument
(
container => …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个脚本,我需要在几个地方使用文件测试的输出,包括shell函数内部.我想将文件存在分配给shell变量,如下所示:file_exists=[ -f $myfile ]
.
为了确保我已经覆盖了我的基础,我首先触摸一个文件,并测试它的存在:
file='a'
touch $file
if [ -f $file ]
then
echo "1 -- '$file' exists"
fi
Run Code Online (Sandbox Code Playgroud)
输出:
1 -- 'a' exists
Run Code Online (Sandbox Code Playgroud)
该文件已成功创建 - 没有惊喜,但至少我知道我没有处理任何权限问题或任何事情.
接下来我测试以确保我可以在变量中存储布尔表达式:
mytest=/bin/true
if $mytest
then
echo "2 -- \$mytest is true"
fi
Run Code Online (Sandbox Code Playgroud)
输出:
2 -- $mytest is true
Run Code Online (Sandbox Code Playgroud)
所以,我已经掌握了一些基本覆盖-条件表达式应该发出相同的输出/bin/true
或/bin/false
...但是这不是我所看到的:
mytest=[ -f $file ]
if $mytest
then
echo "3 -- \$mytest is true [expect true]"
else
echo "3 -- \$mytest is false [expect true]"
fi
Run Code Online (Sandbox Code Playgroud)
此操作失败,并显示以下错误:
-f: …
Run Code Online (Sandbox Code Playgroud) 我刚刚了解到,在Perl中,给定模块的符号表存储在与模块名称匹配的哈希中 - 因此,例如,虚构模块的符号表Foo::Bar
就是%Foo::Bar
.默认符号表存储在%main::
.只是为了好奇,我决定要查看其中的内容%main::
,因此遍历哈希中的每个键/值对,在我去的时候将它们打印出来:
#! /usr/bin/perl
use v5.14;
use strict;
use warnings;
my $foo;
my $bar;
my %hash;
while( my ( $key, $value ) = each %:: ) {
say "Key: '$key' Value '$value'";
}
Run Code Online (Sandbox Code Playgroud)
输出看起来像这样:
Key: 'version::' Value '*main::version::'
Key: '/' Value '*main::/'
Key: '' Value '*main::'
Key: 'stderr' Value '*main::stderr'
Key: '_<perl.c' Value '*main::_<perl.c'
Key: ',' Value '*main::,'
Key: '2' Value '*main::2'
...
Run Code Online (Sandbox Code Playgroud)
我期待看到STDOUT和STDERR文件句柄,也许@INC和%ENV ...我不期待看到的是非ascii字符...上面的代码块没有显示的是输出的第三行实际上有一个表示不可打印字符的字形.
我运行脚本并将其管道如下:
perl /tmp/asdf.pl | grep '[^[:print:]]' …
Run Code Online (Sandbox Code Playgroud)