我一直在运行很多Perl代码,以这种方式打破长串:
my $string = "Hi, I am a very long and chatty string that just won't";
$string .= " quit. I'm going to keep going, and going, and going,";
$string .= " kind of like the Energizer bunny. What are you going to";
$string .= " do about it?";
Run Code Online (Sandbox Code Playgroud)
从我的Java背景来看,构建一个像这样的字符串将是一个禁忌的表现.Perl也是如此吗?在我的搜索中,我已经读过join在字符串数组上使用是连接字符串的最快方法,但是当你想要分解字符串以提高可读性时呢?写作更好:
my $string = "Hi, I am a very long and chatty string that just won't" .
" quit. I'm going to keep going, and going, and going," . …Run Code Online (Sandbox Code Playgroud) 为什么打印换行需要这么长时间?这只是我的机器,还是别人看到同样的效果?
使用换行符:
#!/usr/bin/perl
use strict;
use Benchmark;
timethis(100000,'main();');
sub main {
print "you are the bomb. \n";
}
# outputs:
# timethis 100000: 8 wallclock secs ( 0.15 usr + 0.45 sys = 0.60 CPU) @ 166666.67/s (n=100000)
Run Code Online (Sandbox Code Playgroud)
没有换行:
#!/usr/bin/perl
use strict;
use Benchmark;
timethis(100000,'main();');
sub main {
print "you are the bomb. ";
}
# outputs:
# timethis 100000: 0 wallclock secs ( 0.09 usr + 0.04 sys = 0.13 CPU) @ 769230.77/s (n=100000)
# (warning: too few iterations …Run Code Online (Sandbox Code Playgroud) 假设我们有Java代码:
Object arr = Array.newInstance(Array.class, 5);
Run Code Online (Sandbox Code Playgroud)
那会跑吗?作为进一步的说明,如果我们尝试这样的事情怎么办:
Object arr1 = Array.newInstance(Array.class, 2);
Object arr2 = Array.newInstance(String.class, 4);
Object arr3 = Array.newInstance(String.class, 4);
Array.set(arr1, 0, arr2);
Array.set(arr1, 1, arr3);
Run Code Online (Sandbox Code Playgroud)
那么arr1会是一个2D数组,相当于:
String[2][4] arr1;
Run Code Online (Sandbox Code Playgroud)
怎么样:如果我们在运行时之前不知道这个数组的尺寸怎么办?
编辑:如果这有帮助(我相信它会...)我们试图从表单的字符串解析未知维度的数组
[value1, value2, ...]
Run Code Online (Sandbox Code Playgroud)
要么
[ [value11, value12, ...] [value21, value22, ...] ...]
Run Code Online (Sandbox Code Playgroud)
等等
编辑2:如果有人像我一样愚蠢尝试这个垃圾,这里是一个至少编译和运行的版本.逻辑是否合理完全是另一个问题......
Object arr1 = Array.newInstance(Object.class, x);
Object arr11 = Array.newInstance(Object.class, y);
Object arr12 = Array.newInstance(Object.class, y);
...
Object arr1x = Array.newInstance(Object.class, y);
Array.set(arr1, 0, arr11);
Array.set(arr1, 1, arr12);
...
Array.set(arr1, x-1, arr1x);
Run Code Online (Sandbox Code Playgroud)
等等.它只需要是一个巨大的嵌套对象数组
我想知道是否可以使用视图从表中获取前5行.我发现Crystal报告似乎没有内置任何东西来做这件事,或者我会在那里做.
当我查询视图时Select * from qryTranHistory,它返回前5个项目,但是如果我尝试选择特定类型Select * from qryTranHistory Where tID = 45则不返回任何内容,因为前5个中通常没有tID = 45.
是否有可能做到这一点?
可以在Crystal Reports的子报表中完成吗?
我正在对客户工作站上的问题进行故障排除,发现令我惊讶的adodb.dll是,在客户的工作站上无处可寻.
通常,我在文件C:\Program Files\Microsoft.NET\Primary Interop Assemblies夹中看到该文件.
此文件是否随.NET框架一起分发?
这两个free(NULL)和::operator delete(NULL)是允许的.分配器概念(例如std :: allocator是否允许deallocate(NULL,1),或者是否需要自己保护它?
我有两个网站使用相同的@ font-face代码.字体文件托管在各自的站点上,路径正确.
一个工作,一个不工作.(当然,它适用于我的个人网站,而不是客户!)
我真的很感激对此的一些新观点!
该网站:http://example.com/
CSS文件:http://365.example.com/index.php? css = photos/style.v.1275845154
相关代码:
@font-face {
font-family: 'JournalRegular';
src: url('./themes/fonts/journal.eot');
src: local('Journal Regular'), local('Journal'), url('./themes/fonts/journal.ttf') format('truetype');
}
body{
background: url("http://labs.example.com/personal/library/images/BG.jpg");
height: 100%;
width: 100%;
margin: 0;
padding: 0;
font-family: 'JournalRegular', Georgia, 'Times New Roman', Times, sans-serif;
color: #999;
}
Run Code Online (Sandbox Code Playgroud)
CSS文件:http://www.example.org/wp-content/themes/theme/style.css
相关代码:
@font-face {
font-family: 'JournalRegular';
src: url('http://example.org/wp-content/themes/theme/fonts/journal.eot');
src: local('Journal Regular'), local('Journal'), url('http://example.org/wp-content/themes/theme/fonts/journal.ttf') format('truetype');
}
.title h1{
float:left;
background:url(images/blt-ttl1?.png) no-repeat 0 4px; …Run Code Online (Sandbox Code Playgroud) 我在几个不同的Subversion存储库中有很多预先存在的项目和代码.我计划通过将一些更简单/即将成为多开发人员项目迁移到Git来让我的脚趾湿透Git.我有几个问题:
如果我从托管的Git解决方案开始,是否很难更改项目的Git服务器(在Subversion中,您只需更改URL等)?在本地安装和维护我自己的服务器之前,我会这样做以启动并运行并熟悉Git.
将我的数据从Subversion迁移到Git有哪些好的步骤?我是否必须查看SVN的每个修订版,导出并提交给Git以获取历史记录?
你遇到过的任何陷阱?
改变的几个原因:我们做了大量的分支和合并,我们将在这些项目上添加一些开发人员,我们将让开发人员不总是在办公室/网络/等.
我有AVAudioRecorder和AVAudioPlayer的问题.
当我同时使用播放器和录音时(例如,录音时播放声音)声音在安静的内置扬声器中.我搜索了stackoverflow,我找到的就是这段代码:
UInt32 *audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
Run Code Online (Sandbox Code Playgroud)
但这对我没有帮助:(当我复制它时,我有错误.我能做些什么来录制和播放底部的扬声器?
我没有像SCLister那样使用任何东西......
提前致谢
马克斯
java ×2
perl ×2
.net-2.0 ×1
adodb ×1
allocator ×1
arrays ×1
benchmarking ×1
c++ ×1
css ×1
distribution ×1
dynamic ×1
font-face ×1
fonts ×1
frameworks ×1
free ×1
git ×1
iphone ×1
migration ×1
null ×1
performance ×1
sql ×1
string ×1
svn ×1
swing ×1
typography ×1