由买买提看人间百态

topics

全部话题 - 话题: perl
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
w**2
发帖数: 724
1
【 以下文字转载自 Programming 讨论区 】
发信人: wds2 (阿旺), 信区: Programming
标 题: perl sprintf question converting dec to hex
发信站: BBS 未名空间站 (Wed Mar 4 17:42:19 2015, 美东)
hi i have this line,
$MACAddress = sprintf("%06x", $MACAddress);
1. when $MACAddress was -1, this line converts it to ffffffffffffffff
instead of ffffffff, i'm on a 32-bit linux pc.
why ?
2. in my code, i need to write $MACAddress twice.
how to use some shortcut e.g. $1 ?
Thanks !
BTW, i LOVE Perl, :)
w*s
发帖数: 7227
2
【 以下文字转载自 Programming 讨论区 】
发信人: wds (大盘5000不是梦), 信区: Programming
标 题: Perl Q: how to convert integer to MAC address
发信站: BBS 未名空间站 (Fri Mar 24 23:10:08 2017, 美东)
81952921372024 => 78:45:c4:26:89:4a
求简洁明快的perl程序
谢谢!
b*h
发帖数: 353
3
这 是 我 的 CODE:
#!C:\perl\bin\perl.exe -wT
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
print $q->header;
print $q->start_html(-title=>'writing to a file');

open csv_file, "> /test.txt" or die "Could not open file$!";
print csv_file "It is a test!!!\n";
close csv_file;

print $q->end_html();
我 想 把 “It is a test!!!”写 到 Apache 的 DocumentRoot 下 一 个 叫 test.
txt 的文 件 里, 可 是 我 运 行 这 个 CODE 后, test.txt里 什 么 都 没 写 上
。 请 问 知 道 的 朋 友 这 是 为 什 么 ? 我 如 何
b*h
发帖数: 353
4
上周曾问过这个问题,可能大家都去渡长周末了,只有一个人回了一下。到现在我这个
问题还没解决,请知道的朋友给指点一下。
这 是 我 的 CODE:
#!C:\perl\bin\perl.exe -wT
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
print $q->header;
print $q->start_html(-title=>'writing to a file');
open csv_file, "> /test.txt" or die "Could not open file$!";
print csv_file "It is a test!!!\n";
close csv_file;
print $q->end_html();
我 想 把 “It is a test!!!”写 到 Apache 的 DocumentRoot 下 一 个 叫 test.
txt 的文 件 里, 可 是 我 运 行 这 个 CODE 后, test.txt里 什 么 都 没 写 上
。 请
w***y
发帖数: 6251
5
来自主题: Programming版 - perl里面的seek怎么用呢?
我现在有一个很大的文件,还有一个该文件的PTR文件
这个PTR文件的每一行记录了一个我要读取的record的名字,起始位置,行数
我怎么用perl里的类似seek的函数找到那个位置读出正确的内容呢?
好比PTR的一行是7 12142 881
我把数据文件打开 为F, 我用sysseek(F, 12142, SEEK_SET) 然后不管用 还是getc
(F)读到的内容都是不对的
perl里面的seek应该怎么用呢?
多谢多谢!
e*t
发帖数: 9
6
来自主题: Programming版 - PERL help!
I am a beginner of perl. I am using perl under linux, but when I use
"use IO:Tee"
I got the following error message
"Can't locate IO/Tee.pm in @INC (@INC contains: /usr/lib64/perl5/5.8.5/x86_
64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/p
erl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.
8.4/x86_64-linux-thread-multi /usr/lib64/perl5/site_p
erl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.2/x86_64-
linux-thread-multi /usr/lib64/perl5/site_per
f*******y
发帖数: 988
7
来自主题: Programming版 - 精通perl的人都是从事什么工作的?
纯粹好奇,觉得perl的语法非常自由散漫,简单的事情无数种方法都可以写出来,还有
无数module;不知道哪些人,或者日常工作做些什么才可以精通perl
n******6
发帖数: 1829
8
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: newegg06 (egg), 信区: SanFrancisco
标 题: 你认为ubuntu下面写script,用perl还是python更好?
发信站: BBS 未名空间站 (Sun Oct 21 01:04:38 2007)
如果执行perl或者python的script,需要另外安装解释器么?
l**********r
发帖数: 4612
9
【 以下文字转载自 Linux 讨论区 】
发信人: linuxbeginer (linux), 信区: Linux
标 题: 关于perl和linux shell script的书最经典有哪些?
发信站: BBS 未名空间站 (Thu Oct 25 08:58:39 2007)
想学习写perl script和linux shell script。 高手推荐几本经典书吧。
f**c
发帖数: 629
10
来自主题: Programming版 - Help: a Perl script question, Thanks (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: flac (fish), 信区: JobHunting
标 题: Help: a Perl script question, Thanks
发信站: BBS 未名空间站 (Fri Feb 29 00:50:35 2008)
assuming the following database table:

create table userinfo (
id int not null primary key auto_increment,
username varchar(12) not null,
salary int not null
);
And assume that using Perl DBI, you can access the database with:
use DBI;
my $drh = DBI->install_driver("mysql");
my $dbh = DBI->connect( "DBI:my
j********r
发帖数: 21
11
来自主题: Programming版 - Perl/Python/.NET难道是搞网页的?
What you really need to learn is C/C++. Java and C# are easier to pick up if
you know C++ well. I did Perl on needed base. There is no need to learn
something you won't use it.
The real deal is to possess the ability to learn things on job.
I know Perl well and it's C-style script language and I like it. I don't
know much about python.
h*********o
发帖数: 62
12
来自主题: Programming版 - New "KENG" about Perl.
read Perl Programming again noted:
(Temp -=32) *=5/9
will be different in C and perl. Interesting!
h*********o
发帖数: 62
13
来自主题: Programming版 - New "KENG" about Perl.
do not have the book with me.
if you happen to have the book. it should be on page 25 or 26 second edition
. It is all about how the assignment returns in perl. As said by Larry,
perl returns variable value.
I**********s
发帖数: 441
14
来自主题: Programming版 - One more "keng" about Perl
This is a bug of Perl's regular expression.
What will "(a)|(b)\1|(b)\2" match in "bb"?
The perl script below shows that "(a)|(b)\1|(b)\2" matches the empty string
"" before "bb", which can't be correct.
do {
print "Enter a regular expression: ";
$re = ;
chop($re);
do {
print "Enter a string: ";
$_ = ;
chop($_);
if (m/$re/) {
print "$re matches \"$&\" in $_\n"; # the matched part.
print "\$` = $`\n"; # the part of the string before the match.
print "\$'
F*******i
发帖数: 190
15
来自主题: Programming版 - perl to html
请问 怎么生成象
http://perldoc.perl.org/functions/wantarray.html
这样有syntax highlight 的 perl script html ?
有什么free 的工具吗?
谢谢
m****n
发帖数: 68
16
来自主题: Programming版 - perl 弱问
用perl出DOE,
matlab 的这句
a = [2:2:6 24 30:3:36]
# generate vector 2 4 6 24 30 33 30
有没有perl 对应的build in 一句搞定呀, 多谢
j******y
发帖数: 700
17
来自主题: Programming版 - perl debugger 请较大虾们
在perl debugger里面(也就是perl -d)怎么能看到我现在的所有的variable呢?我用
了V但是只能看到系统的变量,看不到我自己的script里面定义的变量。
还有就是如何能够看到每个变量它的内存使用情况,比如 $a 占用了 20M的内存空间
谢谢大家了!
n*w
发帖数: 3393
18
来自主题: Programming版 - 为什么一说文本处理就提perl
是不是因为perl两个语言特性
1. tie
2. regular express 和语言紧密结合
perl的regular express似乎可以做到别的script语言做不到的一些功能。但也慢点。
tie相对python的open有什么优势?
d***q
发帖数: 1119
19
来自主题: Programming版 - 介绍一个PERL的书吧。
programming in perl is the suckest perl book i ever seen
c**y
发帖数: 2282
20
来自主题: Programming版 - perl用DBI操作MySQL出错的问题
在执行这句的时候:
$sth->execute($file,$comments);
如果由于数据库方面的原因出错,(例如主键重复),perl方面将给出一个出错信息并
退出。但是我不想让perl退出啊,该怎么办?
w******r
发帖数: 201
21
【 以下文字转载自 Linux 讨论区 】
发信人: warrener (淮水东边旧时月), 信区: Linux
标 题: perl能不能一次把一个str中的a替换成x,b替换成y?
发信站: BBS 未名空间站 (Wed Feb 25 15:20:35 2009)
perl能不能批处理作字符串替换?
比方说把一个字符串中的a替换成x,b替换成y?
我知道可以
$str =~ s/a/x/g
$str =~ s/b/y/g
但这样要做2次scan,而且这样的a-x,b-y规则我有好多条,如果能一次替换就方便多了
c**m
发帖数: 30
22
perl.tr is equivalent to python.translate.
disclaimer: I don't know perl.
r****t
发帖数: 10904
23
来自主题: Programming版 - PERL新手请高手推荐perl的IDE
perl 的高手可能都不用 IDE 的。
c****m
发帖数: 824
24
【 以下文字转载自 Linux 讨论区 】
发信人: ccccmm (猪喂曼玉), 信区: Linux
标 题: 这个perl的小程序为什么不work?
发信站: BBS 未名空间站 (Thu Mar 19 18:35:49 2009)
在call by reference函数里change hash,为什么出来就没有了?
#!/usr/bin/perl -w
use strict;
sub sethash
{
my (%hash) = %{$_[0]};
$hash{1} = 5;
print("$hash{1}\n");
}
my %mainhash = ();
&sethash(\%mainhash );
print("$mainhash{1}\n");
t*********n
发帖数: 278
25
来自主题: Programming版 - 请教 PHP vs Perl
I wrote a perl script for handling the web forms at the web server. And then
, someone told me that PHP is more popular. it is why i want to know the
difference between php and perl. thanx.
t*********n
发帖数: 278
26
来自主题: Programming版 - perl question
用PERL写了个WEB CRAWLER。但是遇到了一点小问题。我要访问的一个网站用了SPLASH
PAGE。 在WEB下,可以看到是一个广告的FALSH, 如果你等10秒,就会把你带到MAIN
PAGE.或者点击LINK, 也可以把你带到MAIN PAGE。 但是我这个PERL的WEB CRAWLER 总
是读取INTRO PAGE, 也就是那个带有广告的PAGE. 该如何读取真正的main page呢?谢
谢。
s********1
发帖数: 581
27
做vision或者graphics的公司要用perl,php,python吗?
这些公司的软件一般是用c++写的。那么软件的用户界面哪?尤其是server端的界面哪
?要用perl,php,python吗?哪种最有用?
谢谢!
w******p
发帖数: 166
28
来自主题: Programming版 - 谁给推荐一个中文perl的论坛
forums suck
start with the book "Learning Perl" and ask google for whatever questions
never ever read the book "programming Perl"
O*******d
发帖数: 20343
29
来自主题: Programming版 - perl or python?
Here is a perl poetry
#!/usr/bin/perl
APPEAL:
listen (please, please);
open yourself, wide;
join (you, me),
connect (us,together),
tell me.
do something if distressed;
@dawn, dance;
@evening, sing;
read (books,$poems,stories) until peaceful;
study if able;
write me if-you-please;
sort your feelings, reset goals, seek (friends, family, anyone);
do*not*die (like this)
if sin abounds;
keys (hidden), open (locks, doors), tell secrets;
do not, I-beg-you, close
I**********s
发帖数: 441
30
来自主题: Programming版 - perl or python?
我一直用Perl.
这个难读不难读跟怎么写有关系吧?
别人说我写的Perl很好读懂的.
c****y
发帖数: 418
31
Not being able to write reusable Perl code is the programmer's problem.
If you are serious about learning Perl instead of bashing it,
maybe you go read Chap 10~14 of the Camel book, assuming you
have one.

of
to
l******e
发帖数: 12192
32
难道Eric Raymond觉得稍大点的项目用python好过用perl,也是程序员自身用perl水平
不行的问题?呵呵
c****y
发帖数: 418
33
From a job security standpoint, Java/C# is often better than
Perl, because they tend to make simple things complicated and complicated
things even more complicated. Kind of the opposite
of Perl :-)

of
some
all
r********3
发帖数: 2998
34
其实,perl可能要写几千行。因为它无法调试,无法复用,所以每次都得重写。你最终
版本可能只有400行,但是中间还是写了几千万。
而Java写2000行,但是下一次如果有所变化,只需要改动几行就够了。
所以,java其实比perl高效。

单t
p****o
发帖数: 1340
35
来自主题: Programming版 - 请教一个perl的替换问题。
怯生生的说一句,我以前真的学过perl的。。。不过这个perl我真得不懂。
d*****u
发帖数: 17243
36
来自主题: Programming版 - perl的hash怎么用汉字做key啊
我对perl不熟
用了汉字作key,比如 好人=>1
总是不能读
换成haoren=>1就可以
是编码问题,还是perl不允许汉字作key?
thanks
p******8
发帖数: 551
37
Please give me some examples ! Thank you!!!
Read line by line with different symbols. Thank you!!!
Any free e- PERL books ?
Thank you!!!
b******n
发帖数: 592
38
search perl cookbook in google
q***2
发帖数: 1861
39
【 以下文字转载自 BuildingWeb 讨论区 】
发信人: qsyd2 (潜水员 - 第二名), 信区: BuildingWeb
标 题: 请教一个技术问题,关于perl 的
发信站: BBS 未名空间站 (Sun Dec 19 02:22:22 2010, 美东)
如果客户要求主站用perl 来写,那要是之后再加添论坛,博克等等插件时用PHP,
PHPbb 等等,会不会出问题?切换速度延迟等等问题至少? 谢谢
l*******t
发帖数: 642
40
就是用perl运行外部程序,这个外部程序可能会出错,比如assertion failure.这个时候
会有window出现,提示Abort, Retry,Ignore.请问如何用perl可以detect这种情况?包子
酬谢! 请指教!
E*********s
发帖数: 11
41
来自主题: Programming版 - 弱问perl写网页buffer问题
程序如下
#!d:/strawberry/perl/bin/perl.exe
#
#use strict;
use CGI;
use IO::Handle;
$myCGI = new CGI;
#$| = 1;
my $url="some url";
print $myCGI->header;
my $test="\n
\n";
STDOUT->autoflush(1);
print $test;
my $time = time();
my $timestamp = localtime($time);
print $timest... 阅读全帖
t****t
发帖数: 6806
42
first of all, the value of macro is dependent on the place that macro is
expanded. for example:
#define A A1
#define A1 1
/* here A expands to 1 */
#undef A1
#define A1 2
/* here A expands to 2 */
therefore your requirement is not very strict.
second, assume that you want only the final value of every macro. you may
use gcc to do that:
gcc -dM -E xxxxxxxx.c > xxxxxx_processed.c
/* it outputs all the (final) macro definitions */
then you use a perl to process it: for every macro name in $_, (each... 阅读全帖
l*****n
发帖数: 72
43

没错!这是最直接了当的方法。 :)
但是我用 Perl 的原因就是这只是整个Program中的一部分,由于牵涉到几层循环,不
能在
AWK 操作里面再做 AWK 操作,所以转向了 Perl。
否则的话无论 AWK或者 Shell 都有很简单的解决办法。
多谢了!
k*******3
发帖数: 1909
44
来自主题: Programming版 - perl eval and if
==========================TryTiny.pl CODE BEGIN====================
#!/usr/bin/perl
use warnings;
use strict;
eval
{
my $i = $foo;
};
if ($@)
{
print "There is an error caught!!!!";
}
==============================CODE END=============================
想用上面代码测试perl错误捕捉,bash下运行显示
Global symbol "$foo" requires explicit package name at TryTiny.pl line 8.
Execution of TryTiny.pl aborted due to compilation errors.
为什么没有捕捉到错误运行print "There is an error caught!!!!";这句呢?
Thanks!
c****f
发帖数: 1102
45
perl的语法结构不OO 不好维护 而且代码难看 风格随程序员而异 不过写起来很爽 哈哈
推荐perl和bash的原因是 基本这些都preinstall在系统里的
r*****t
发帖数: 712
46
来自主题: Programming版 - perl 文档工具?
我想找一个源代码注释工具,有很多的选择,有没有比较容易用的,主要针对perl的?
最好还有一个功能就是能把不同perl script里面相关的函数关联起来,如果一个
script修改了,它会提示我去修改其他受影响的文件,类似VS/Eclipse里面的refactor
的效果。
多谢!
Y*********I
发帖数: 54
47
来自主题: Programming版 - 请教各位先贤一个Perl 问题
各位先贤,
我试着 split file into sentences but got a error message Can't locate Text/
Sentence.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at test1
.pl line 10. BEGIN failed--compilation aborted at test1.pl line 10.
The line 10 is use Text::Sentence qw(split_sentences);
I installed all text related packages.
多谢!
t****t
发帖数: 6806
48
来自主题: Programming版 - 请教各位先贤一个Perl 问题
and where did you install Sentence.pm? The error message is pretty clear,
there is no:
C:/Perl/site/lib/Text/Sentence.pm
C:/Perl/lib/Text/Sentence.pm
./Text/Sentence.pm
If you installed in other directories, add them to @INC.

test1
F****3
发帖数: 1504
49
现在在学Python主要来做text processing,感觉很好学(正在学习,还不是很会)。
但是听说perl是专门用来处理文档的,历史悠久,有很多package。不知道是不是单看
文本处理和NLP这一块,在掌握python的基础上再另外学习perl还是有必要的?
问题可能很白,请牛人们见谅啊!!!
谢谢!
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)