由买买提看人间百态

topics

全部话题 - 话题: perl
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
s*******a
发帖数: 8827
1
perl的regex超好用的,我一条regex规则用c写的话可能就得上百行code才能做到。
而且cpan超强大,基本我所有想到的功能别人都帮我实现好了。用perl写东西就跟搭积
木似的。
c*********e
发帖数: 16335
2
en,用perl, cpan.org是个非常好的地方,你会发现好多人免费写的插件。perl是文本
处理之王,现在银行还用它,它非常简洁。
S**I
发帖数: 15689
3
来自主题: Programming版 - perl oneliner hash疑问
`perl -e '%metrics = (); \$metrics{"Average"} = "SomeValue"; if(exists \$
metrics{\"Average\"}){print \"found\";}' > out.txt`;
This is ugly, though; you should use perl's i/o functions to write to out.
txt.

txt
t****t
发帖数: 6806
4
来自主题: Programming版 - perl oneliner hash疑问
why do you want to run another perl in perl script?
t****t
发帖数: 6806
5
来自主题: Programming版 - perl oneliner hash疑问
well, now you know the "secondary perl" does not inherit anything from the
first perl.
s******o
发帖数: 656
6
来自主题: Programming版 - Python, Java, Perl, PHP,Ruby
求各路大神给小弟指条明路,这几个语言哪个更适用于我的情况
我是学文科的,编程经验很少,之前用过matlab做些简单的运算,转文科后主要用SAS
和stata做统计。没接触过C之类的复杂的语言。最近经常帮RA的老板手工收集数据,例
如从上市公司财务报表中找出需要的信息,手工收集到excel之类的软件以方便SAS读取
。手工收集数据太费时间,以后还可能经常用到,所以想学个语言看能不能编程代替手
工收集。
现在主要的困惑一是心里没啥概念到底编程能不能完全代替手工收集或者省掉大部分手
工时间,因为收集某些数据的时候需要先读一遍报表里的话然后才能决定这段话里提到
的数据是不是我需要的。我网上搜到python里有个natural language tool kit http://nltk.org/ 貌似能分析自然语言,但是不知道这个工具能不能强大到分析报表摘出有用信息。
另外一个搞不清的地方是如果编程能代替手工收集,哪一种语言解决我的问题最有效?
我刚看到FAS133同学发在本版的帖子,他遇到的问题貌似跟我的有点像,帖子里各位有
的说Java适用有的说Perl最好。有点糊涂。http://www.... 阅读全帖
s******o
发帖数: 656
7
来自主题: Programming版 - Python, Java, Perl, PHP,Ruby
多谢!perl跟python比起来哪个更适用我的情况呢?网上看到不止一次说perl分析文本
比较好,没看见有人说python干这个好的,还是只要用regex都差不多?
s******o
发帖数: 656
8
来自主题: Programming版 - Python, Java, Perl, PHP,Ruby
呵呵,你还记得啊!
我当时也是碰到类似的手工收集的问题,想现学现卖,后来发现时间紧自己搞不定,就
找了一个CS的朋友帮忙搞定的。当时我那朋友好像都没有用到编程或者用了一点perl,
大部分直接用shell script就弄好了。那之后我一直没有再做类似的手工收集,就扔下
了。最近又被assign给这个老板做RA,干的事比以前还麻烦。另外就是我们这一行最近
也开始有人在搞类似的东西了,比如说编程模拟大规模手工收集数据,谁有别人没有的
数据谁就能发paper,还有人编程或者用软件分析财务报表的语气发paper的,也算是个
研究的趋势吧,这些东西SAS或者Stata实现起来很难,所以打算认真弄一弄编程语言。
上次学的那点python连皮毛都不是,学了半天也稀里糊涂的,而且我问了一下发现我认
识的人学perl的比较多大部分没用过python没法比较。多谢大神指教!另外还想请教一
下如果nltk不适用,我应该去哪里找我需要的工具呢?光google有点大海捞针的感觉,
我是编程门门外汉也不知道该去哪找。
f******y
发帖数: 2971
9
来自主题: Programming版 - perl cookbook不好读。
Learning Perl + Programming Perl
x**n
发帖数: 1055
10
最近正在看Jeffery的Mastering Regular Expressions一书p69,其中提到将多个连续
的空行替换成一个

的例子:
$text =~s/^s*$/

/mg;
目的是把一个纯文本中的多个空行(可含space和tab)替换为一个html的段落


不过这个命令工作原理似乎不太明白,在增强多行模式/m下,总是出现两个


比如我的文件txt(行号不算):
1 a
2
3
4
5 b
6
7
8
9
10 c
用如下的perl脚本t2h.pl:
#!/usr/bin/perl
undef $/;
$text=<>;
$text=~ s/^s*$/

/mg;
print "$text";
运行结果如下:
>./t2h.pl txt
a


b


c
似乎是什么都没有的空行就不行出现了两个连续的

,如果加了个空格就可以,具体
为什么有点奇怪了
xssn@thinkm57:~/regex$ cat txt -An
1 $
2 a$
3 $
... 阅读全帖

o******1
发帖数: 1046
11
多谢指点!
这个应该可以。就是要修饰一下perl -E 'say for %ENV'输出的格式。直接输出,就是
一行变量名,接着一行变量值,perl似乎不认。
h****g
发帖数: 772
12
不会perl,
读一个小程序
有这两句
$k =~ s/^[^=]*=//;
$k =~ s@\_@@g;
我理解第一句是把从开头到*=都删除,除非以=开头
第二句是把\_删除。
那么它对_有作用吗?
能否等效于python
t = re.sub("^[^=]*=","",t);
t = re.sub(r"\_","",t);
t2:
#!/usr/bin/perl
$s=$ARGV[0];
printf("%s %s \n",$s,&test($s));
sub test {
my($t) = @_;
$t =~ s@\_@@g;
return $t;
}
$ ./t2 _cde
_cde _cde
$ ./t2 \_cde
_cde cde
e*******o
发帖数: 4654
13
1. 是到=号都删除。 星号是和[^=]一起的,
2. 是把_号都删除。 s@\_@@g <=> s@_@@/g <=> s/_//g <=> s{}//g
任何punctuation character都可以。我一般用///. 除非,要match的字符串有/。
When a backslash precedes a nonalphanumeric character in a Perl pattern, it
always makes that next character a literal.
http://docstore.mik.ua/orelly/perl4/prog/ch05_03.htm
你的代码
$s=$ARGV[0]; <=> $s = shift;
my($t) = @_; $t =~ s@\_@@g; return $t; <=> shift =~/_//gr。
你要找learning perl来看。
e*******o
发帖数: 4654
14
来自主题: Programming版 - 说个Perl无与伦比?的优点吧
cpan 上的多数module,都有测试结果可以看,不同的操作系统,构架。
http://www.cpantesters.org/distro/M/Moose.html?oncpan=1&distmat
http://www.cpantesters.org/distro/R/Regexp-Grammars.html?oncpan
每个Perl新版本发行之前,新的版本break了那些module,都是有数据的。perl的维护
者都会讨论break的原因,基本会一一解决。
有没有其它的语言有类似的东西?
就不要说超级好的文档了。我往cpan上传过module,很快就会有测试报告发过来。当时
真是觉得不可思议。
f********a
发帖数: 1109
15
来自主题: Programming版 - 听说polyvore工作语言是Perl? (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: fololunsia (我心飞扬), 信区: JobHunting
标 题: 听说polyvore工作语言是Perl?
发信站: BBS 未名空间站 (Sun Sep 21 13:13:55 2014, 美东)
现在应不应该学习perl?
w**2
发帖数: 724
16
来自主题: Programming版 - Hex byte string syntax in perl please (转载)
【 以下文字转载自 Linux 讨论区 】
发信人: wds2 (阿旺), 信区: Linux
标 题: Hex byte string syntax in perl please
发信站: BBS 未名空间站 (Thu Feb 26 18:21:00 2015, 美东)
so i have a ascii string: 11, 22, 33 ,
(ascii 22 is not readable),
what's the syntax in perl for this string pls,
$str = "0x112233" ?
thanks !
Y*********I
发帖数: 54
17
来自主题: Programming版 - Perl 问题 (updated)
各位先贤,
用Perl怎么才能得到URL的内容(不是source code)?举例来说,这个URL https://
www.sec.gov/Archives/edgar/data/1035002/000103500215000009/vloform10-
kx12312014.htm 是个company 的10-K filing. 怎么用Perl using the URL to get
the 10-K filing?
实在是不懂,让各位见笑了。
多谢!
T******7
发帖数: 1419
18
来自主题: Programming版 - Perl程序员工作机会多吗?
会perl的目前都是40岁以上的人。年轻人学perl不如学java.scala
w*********n
发帖数: 439
19
来自主题: Programming版 - Perl程序员工作机会多吗?
多谢各位回帖,特别是echowuhao大侠,特别是你的转行帖给我莫大的鼓励。
我本来是生物千老,现在不想干生物了,想转行。虽然自学了JAVA,但是找工作还是基
本没戏,因为JAVA的职位都要3-5年工作经验,还要会3大框架,外加HTML,CSS,
javascript,phd等技术,没有2年学不完。
我现在偶然得到一个做生物信息的机会,是在大学的生物信息core做intern,用的是
Perl和Linux。就想问问如果将来要去公司工作的话,Perl+Linux是不是工作机会不多
e*******o
发帖数: 4654
20
来自主题: Programming版 - Perl程序员工作机会多吗?
https://jobs.perl.org
基本上都是perl + linux的
你如果实习能好好学个三个月,找份fulltime 不难.
c******n
发帖数: 4965
21
用来写 1liner 很方便, 有时候我不愿写 shell script ,因为不够强大, 就把Perl
当 shell 用。
不过基本要 reusable 的 python 明显胜过 perl
c*********e
发帖数: 16335
22
难怪现在的新人不知道perl这么大名鼎鼎的语言。最找的网络搜索,就是用perl写的。
x*******t
发帖数: 790
23
Perl 有些人喜欢
我都用,但是比较喜欢python的严谨性
[在 Trojan07 (usc) 的大作中提到:]
:听好多大牛说perl是很好的语言,很奇怪先在这语言掀不起任何风浪
:可能主要还是蟒蛇太变态
:...........
x*******t
发帖数: 790
24
perl太多种写法了
[在 NeverLearn (24K golden bear) 的大作中提到:]
:【 在 Trojan07 (usc) 的大作中提到: 】
:: 听好多大牛说perl是很好的语言,很奇怪先在这语言掀不起任何风浪
:...........
w*s
发帖数: 7227
25
来自主题: Programming版 - 请推荐perl web framework
Yes, while i'm working on node.js, i still love perl, :)
The old web product is based on old perl CGI, i'm looking to the simplest
way to fix XSS/Sql injection/etc. web security holes.
So for Catalyst Dancer Mason Maypole Mojolicious
which one should i use in the ARM platform ? Thank you !
f*****w
发帖数: 16
26
Elements of Programming with Perl
Andrew L. Johnson
the evaluation is not bad. seems more basic than "learning perl"
o*******e
发帖数: 31
27
来自主题: Unix版 - CGI之Perl Script一问
use system in perl is just like u excute
any unix command or shell script in unix
shell.
That means u can call any unix command or
useful script from the yr cgi perl
a***a
发帖数: 62
28
ok, Now i install that in my private directory, such as
~/lib/perl/Net/Telnet.pm
and change the PATH env include that
but it still say can't locate it, it only search in
/pkg/perl..... not my directory, do u know what's wrong?
m*******y
发帖数: 233
29
来自主题: Unix版 - [转载] Perl高手请进
【 以下文字转载自 Programming 讨论区 】
【 原文由 mannotcry 所发表 】
two questions:
1. Use 'perl -u' can dump a core of the complilation of a script. How can
I undump the core to the excutable?
2. How can I limit the memory that can be used by a perl script?
Thanks a lot.
j***y
发帖数: 2074
30
in short, The Perl CD Bookshelf.
over $100 in bookstore. quite expensive, but worth the money. quite clear and
concise. you can refer to it while programming in perl.
strongly recommend it.
s*******l
发帖数: 8
31
I have a perl program which will create a file. I set the setuid permission
for the perl program, say: chmod 6755 myperl.pl
Then, when I execute it as other users, either the created file is owned by
another user (say, root), or an error happened and the program can not be
run by others:
Insecure ENV{$PATH} ....
How to deal with this? Thanks a lot.
p******f
发帖数: 162
32
来自主题: Unix版 - How to edit @INC array for perl?

which perl executable are you using, show it by perl -v.
if you are still using the old one, use alias or path to
find the 5.8.0 one.
T*****e
发帖数: 361
33
来自主题: Unix版 - [转载] Help! About PERL system()
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: ThatOne (ThatOne), 信区: Programming
标 题: Help! About PERL system()
发信站: The unknown SPACE (Mon Oct 21 22:55:43 2002) WWW-POST
I am writing a perl script to mantain a website. The script (sss) creates two
files( a, b). Then these two files are translated into three other files (c,
d, e) by another executable file (eee) writen in C++. After a and b have been
created, I can run eee at command line to have them translated without any
problem. However, when I
i**********r
发帖数: 36
34
【 以下文字转载自 Linux 讨论区 】
【 原文由 interstellar 所发表 】
how can i list all variables used in a perl subroutine?
i used to perl -d to do a very simple check, but it does not
list the variables used.
thanks,
s**n
发帖数: 2
35
大家好,
最近在写一个程序,可以自动生成信件,然后发给客户。在UNIX下我用PERL调用sendmail,
可以发送文本信息,但却不知如何发送附件。在网上搜了一通,很多人
问过这个问题,有人说至少有两种途径:1)use Net::SMTP module 2) use UNIX
sendmail directly. 很多人讲第二种很可行,但没有提供源码。

somebody posted the following to do the job, but after I test it, it didn't
work well, some unreadable text was APPENDED to the email, not attached.
Who can help me?
#!/usr/bin/perl
# Set Variables
$mailprog = "/usr/lib/sendmail";
$youremail = "r*****[email protected]"; # Your Email Address
$yourname = "Rickyao"; # Your
z*****u
发帖数: 12
36
来自主题: Unix版 - [转载] perl: regex
sorry i should not have said that...
perl's philosophy is that "there's always a better way to do it..." and of
course, there's always people who know better way to do it. you are absolutely
in the right perl thinking mode. :)
if the file is not too big, i would do this
while(<>) {
foreach $word (split) {
if ($word =~ /^cbo-[0-9]*$/i) {
push @cbo_strings, $word;
}
}
}
print @cbo_strings;
#share with us if you have better idea...

go
w*******h
发帖数: 8
37
来自主题: Unix版 - 如何在perl中运行c-shell file?
现有一c-shell file, 它可以调用一个fortune程序, 但是每次只能执行一个输入纪录,得
到一个输出结果. 为了能让它执行多个纪录, 另外写一个脚本程序(use perl),做循环,每
遇到一个纪录九调用一次c-shell file, 处理这个纪录, 得到输出结果, 请问在perl中如
何调用c-shell file?
thanks in advanced
m******y
发帖数: 588
38
【 以下文字转载自 Linux 讨论区 】
【 原文由 mirthcyy 所发表 】
I want to write a Is_Float function in perl, but I don't know
how to express it with Perl Regular expression. Please help me
if you know that. Thanks a lot.
m******a
发帖数: 2
39
来自主题: Unix版 - perl , ssi 问题
this is right suggestion

scripts?
情况是这样:学校的os是sun的unix,而且可以编译运行perl程序。但是我在shtml里用
perl
x*********g
发帖数: 11508
40
来自主题: Unix版 - Perl和Python哪个更好呀?
个人认为,如果有OO编程经验,python更适合一些,如果没有,那么Perl更容易一些。当
然现在Perl也有面向对象的了。但是我个人还是更喜欢JSP。
x*********g
发帖数: 11508
41
来自主题: Unix版 - Perl和Python哪个更好呀?
哈哈,看来老兄是Perl的坚定支持者。我只是说各有用处,您老兄就开始攻击python和Ja
va了。
http://www.zope.org/ 是用python写的。
Java的工作机会比Perl和python可是多得多得多了,都不是一个数量级的,难道这还不够
说明问题吗?

web
mod_perl)
you
JSP
x*********g
发帖数: 11508
42
来自主题: Unix版 - Perl和Python哪个更好呀?
really? What is the average salary I may expect as a perl/python programmer?
I'm so curious to know.

哈哈,看来老兄是Perl的坚定支持者。我只是说各有用处,您老兄就开始攻击python和Ja
不够
commercial
develope
b*m
发帖数: 5
43
来自主题: Unix版 - Perl和Python哪个更好呀?
I won't recommand python. Its syntax really sucks. And also, its thead
support / scalability is nowhere close to java. This is why java is
accepted by the large companies.
If you don't have enough OO experience and perl programming experience, don't
try OO perl. you will be lost.

b*m
发帖数: 5
44
来自主题: Unix版 - Perl和Python哪个更好呀?

唉,看贴子要在字里行间看出省略掉的形容词。就好比前面有人说Amazon用perl,google

--- 都是核心application

----------java 都是辅助application. C/C++
通常都是用在比perl/python更关键的地方.
Ja
a*****j
发帖数: 13
45
来自主题: Unix版 - perls questions //bow
is it possible that I push filehandles into an array
like the following:
for($i=0; $i<10; ++$i)
{
open(tmp,"./abc.txt") or die(...);
push(@file_list, $tmp);
}
....
while(@file_list)
close(pop(@file_list));
I used the similar code like the above, but it gave me compilation errors.
another question: wot is the option that I should use to see compilation
errors from perl?
I am a pretty newbee in perl, please help!
//bow
f****y
发帖数: 70
46
来自主题: Unix版 - perl出错求教
情况是这样地,本来可以运行的,
后来可能是在运行的时候disk满了,我是后来看到数据没有生成,看disk几乎满了,就
去check,delete了一下file,也不知道有没有delete到什么需要的文件,应该和perl没
有关系。
当我把disk清出空间后,再运行这个perl script就出现了这个错误。
l**********r
发帖数: 4612
47
【 以下文字转载自 Linux 讨论区 】
发信人: linuxbeginer (linux), 信区: Linux
标 题: 关于perl和linux shell script的书最经典有哪些?
发信站: BBS 未名空间站 (Thu Oct 25 08:58:39 2007)
想学习写perl script和linux shell script。 高手推荐几本经典书吧。
xt
发帖数: 17532
48
来自主题: Unix版 - Perl问题求助 (转载)
【 以下文字转载自 Linux 讨论区 】
发信人: xt (拷贝猫), 信区: Linux
标 题: Perl问题求助
发信站: BBS 未名空间站 (Wed Apr 23 11:34:20 2008)
需要调用一个shell command,然后检查stdout的输出值,类似
这种:
ls foo.txt |wc -l
这一段要写在perl里,我需要检查这个值是否大于零。
这个怎么做?
谢谢
b****n
发帖数: 144
49
来自主题: Unix版 - Perl问题求助
【 以下文字转载自 Programming 讨论区 】
发信人: barron (barron), 信区: Programming
标 题: Perl问题求助
发信站: BBS 未名空间站 (Wed Sep 22 15:09:54 2010, 美东)
我用perl写了一个读取1.7M txt文件到string array,然后进行一些字符串替换,再将
string array存入一个新的txt文件的小程序,可是新建的新文件没有多多少内容,siz
e却变成了8M,而且每行末尾有些乱码,做了dos2unix以后,乱码消失,size不变。。。
请问这个可能是什么问题,怎样才能保持文件的size不变? 谢谢!
o*********e
发帖数: 7
50
来自主题: AnthroLing版 - 怎样用Perl处理中文文件?
我使用英文版的windows。请问如何用Perl script处理中文文件?需从CPAN上下载什么
modules和字库吗?有没有简单的example script可以看一看?另外,什么text editor
可以保存utf, unicode, 以便用来写中文Perl script?
再一问题是,我的计算机是64bits 的。我只找到32 bits 的nmake.ext。哪里可找到64
bit 的?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)