Tag Archive for 'perl'

Page 2 of 2

Perl安装问题

Perl在测试服务器上安装perl5.8.8

1
2
$./configure.gnu --codefix=$HOME/local
make

结果出错啦~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
make[1]: Leaving directory `/home/.salk/ndw/src/perl-5.8.6/x2p'

        Making B (dynamic)
opendir(./../../../../..): Permission denied at ../../lib/File/Find.pm line 597
Use of chdir('') or chdir(undef) as chdir() is decodecated at ../../lib/File/Find.pm line 741.
opendir(./..): Permission denied at ../../lib/ExtUtils/MakeMaker.pm line 165
Couldn't change to directory /home/.salk/ndw/C: No such file or directory at Makefile.PL line 18
Writing Makefile for B
Warning: No Makefile!
make[1]: Entering directory `/home/.salk/ndw/src/perl-5.8.6/ext/B'
make[1]: *** No rule to make target `config'.  Stop.
make[1]: Leaving directory `/home/.salk/ndw/src/perl-5.8.6/ext/B'
make config failed, continuing anyway...
make[1]: Entering directory `/home/.salk/ndw/src/perl-5.8.6/ext/B'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/.salk/ndw/src/perl-5.8.6/ext/B'
make: *** [lib/auto/B/B.so] Error 2

1
$make minitest

来测试,结果在98.5%的地方出错了,没有办法,GOOGLE上搜索了一下,结果是编译的地方出错了,在 /tmp 下面编译一点问题都没有,看来是不是以后都要改变一下编译的习惯了? ;)

1
/tmp$ ./configure.gnu --codefix=$HOME/local && make && make test && make install
Share

HOT PERL ONLINERS

Just enough perl to do most everything! Tom Christianson (spelling?)
once posted a canonical list of one line perl programs to do many common
command-line tasks.
It included:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# run contents of "my_file" as a program
perl my_file

# run debugger "stand-alone"
perl -d -e 42

# run program, but with warnings
perl -w my_file

# run program under debugger
perl -d my_file

# just check syntax, with warnings
perl -wc my_file

# useful at end of "find foo -print"
perl -nle unlink

# simplest one-liner program
perl -e 'print "hello world!\n"'

# add first and penultimate columns
perl -lane 'print $F[0] + $F[-2]'

# just lines 15 to 17
perl -ne 'print if 15 .. 17' *.pod

# in-place edit of *.c files changing all foo to bar
perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c

# command-line that prints the first 50 lines (cheaply)
perl -pe 'exit if $. > 50' f1 f2 f3 ...

# delete first 10 lines
perl -i.old -ne 'print unless 1 .. 10' foo.txt

# change all the isolated oldvar occurrences to newvar
perl -i.old -pe 's{\boldvar\b}{newvar}g' *.[chy]

# command-line that reverses the whole file by lines
perl -e 'print reverse <>' file1 file2 file3 ....

# find palindromes
perl -lne 'print if $_ eq reverse' /usr/dict/words

# command-line that reverse all the bytes in a file
perl -0777e 'print scalar reverse <>' f1 f2 f3 ...

# command-line that reverses the whole file by paragraphs
perl -00 -e 'print reverse <>' file1 file2 file3 ....

# increment all numbers found in these files
perl i.tiny -pe 's/(\d+)/ 1 + $1 /ge' file1 file2 ....

# command-line that shows each line with its characters backwards
perl -nle 'print scalar reverse $_' file1 file2 file3 ....

# delete all but lines beween START and END
perl -i.old -ne 'print unless /^START$/ .. /^END$/' foo.txt

# binary edit (careful!)
perl -i.bak -pe 's/Mozilla/Slopoke/g' /usr/local/bin/netscape

# look for dup words
perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi'

# command-line that prints the last 50 lines (expensively)
perl -e 'lines = <>; print @@lines[ $#lines .. $#lines-50' f1 f2 f3 ...
Share

Perl Package Manager

这两天挺累的,有好消息,也有坏消息,我尽量保持冷静,毕竟,这是应该的。来成都第三个月,好好坏坏都经历过了,仿佛生活就是在用不同的方式去考验每一个,直到自己能够接受,或是重新再领悟过去,憧憬未来,好好过者现在。我试着去帮助每个人,而不是为了自己,我想这样生活会更有意义的,不是吗?

perl在Windows上使用Perl的模块怎么办?用CPAN很麻烦的,使用ActivePerlPPM来管理吧,安装、升级、删除都可以方便的进行,可以使用GUI也可以使用命令行。不过在Cygwin我使用PPM失败了,不知道为什么,一会检查一下,哈哈,休息一下,整理一下心情的碎片,一天接一天,幸福就会一天天接近,不是吗?

Share

Perl script on cgiwrap

If I use some script like this

1
2
#!/usr/bin/perl
print "Hello World!";

It will give me error :

1
[Wed Aug 16 08:57:50 2006] [error] [client 222.209.97.197] malformed header from script. Bad header=Hello World...: /www/cgiwrap/cgi/cgiwrap

And I must do like this:

1
2
3
4
#!/usr/bin/perl
use CGI qw(:standard);
print header('Welcome to my home page!');
print start_html(), "Linux and PHP", end_html();
Share

查看所安装的 Perl 模块

Perl modules今天在perlchian的mail-list上有人提出这样的问题

如何查看已经安装的perl模块?

问答是这样的

1
2
3
4
use ExtUtils::Installed;

my $inst = ExtUtils::Installed->new();
print join "\n", $inst->modules();

在我的 ubuntu dapper 上则看到这些模块,很显然,我在公司的个人工作电脑上还不是很喜欢用 perl 。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ perl
use ExtUtils::Installed;
my $inst = ExtUtils::Installed->new();
print join "\n", $inst->modules();
Archive::Tar
Archive::Zip
Comcodess::Zlib
Cwd
Digest::SHA
File::HomeDir
Module::Build
Module::Signature
Net::Telnet
Perl
Spiffy
Term::ReadKey
Term::ReadLine
Test::Base
Test::Simple
Text::Glob
YAML
Share