• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Perl命令常用选项

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

-e:告诉perl在其后的命令行里查找运行代码。当然只能用于输入一行代码执行,如果要运行的代码不止一行,参数就变了。

xk@linux:~/work> perl -e 'print "hello!"n";'

hello!

xk@linux:~/work>

-:告诉perl在其后的命令行里查找运行代码,直到遇到__END__为止。

xk@linux:~/work> perl -

print "hello"n";

print "world!";

__END__

hello

world!xk@linux:~/work>

-c:用来检查脚本的语法而不执行它。

xk@linux:~/work> cat t

#!/usr/bin/perl

print "hello";

xk@linux:~/work> perl -c t

t syntax OK

xk@linux:~/work>

-h:帮助选项,用来打印perl的全部选项信息。

xk@linux:~/work> perl -h

Usage: perl [switches] [--] [programfile] [arguments]

 -0[octal]       specify record separator ("0, if no argument)

 -a              autosplit mode with -n or -p (splits $_ into @F)

 -C[number/list] enables the listed Unicode features

 -c              check syntax only (runs BEGIN and CHECK blocks)

 -d[:debugger]   run program under debugger

 -D[number/list] set debugging flags (argument is a bit mask or alphabets)

 -e program      one line of program (several -e's allowed, omit programfile)

 -F/pattern/     split() pattern for -a switch (//'s are optional)

 -i[extension]   edit <> files in place (makes backup if extension supplied)

 -Idirectory     specify @INC/#include directory (several -I's allowed)

 -l[octal]       enable line ending processing, specifies line terminator

 -[mM][-]module execute `use/no module...' before executing program

 -n              assume 'while (<>) { ... }' loop around program

 -p              assume loop like -n but print line also, like sed

 -P              run program through C preprocessor before compilation

 -s              enable rudimentary parsing for switches after programfile

 -S              look for programfile using PATH environment variable

 -t              enable tainting warnings

 -T              enable tainting checks

 -u              dump core after parsing program

 -U              allow unsafe operations

 -v              print version, subversion (includes VERY IMPORTANT perl info)

 -V[:variable]   print configuration summary (or a single Config.pm variable)

 -w              enable many useful warnings (RECOMMENDED)

 -W              enable all warnings

 -x[directory]   strip off text before #!perl line and perhaps cd to directory

 -X              disable all warnings 

xk@linux:~/work>

-S:让perl使用PATH环境变量来搜索脚本。

xk@linux:~/work> echo $PATH

/home/xk/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin

xk@linux:~/work> cd ../bin/

xk@linux:~/bin> ls

xk@linux:~/bin> cat >test.pl<<eof

> #!/usr/bin/perl

> print "hello"n";

> eof

xk@linux:~/bin> chmod a+x test.pl

xk@linux:~/bin> cd ../work

xk@linux:~/work> perl -S test.pl

hello

xk@linux:~/work>

-T:强制打开错误检查(数据安全性检查),经常用在CGI中。

 

-v:打印出perl的版本以及包的级别。

xk@linux:~/work> perl -v

 

This is perl, v5.8.6 built for i586-linux-thread-multi

 

Copyright 1987-2004, Larry Wall

 

Perl may be copied only under the terms of either the Artistic License or the

GNU General Public License, which may be found in the Perl 5 source kit.

 

Complete documentation for Perl, including FAQ lists, should be found on

this system using `man perl' or `perldoc perl'. If you have access to the

Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 

xk@linux:~/work>

-V:打印出perl的全部配置信息。

xk@linux:~/work> perl -V

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:

 Platform:

    osname=linux, osvers=2.6.9, archname=i586-linux-thread-multi

    uname='linux salieri 2.6.9 #1 smp fri jan 14 15:41:33 utc 2005 i686 athlon i386 gnulinux '

    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true -Doptimize=-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -g -Wall -pipe'

    hint=recommended, useposix=true, d_sigaction=define

    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define

    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef

    use64bitint=undef use64bitall=undef uselongdouble=undef

    usemymalloc=n, bincompat5005=undef

 Compiler:

    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',

    optimize='-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -g -Wall -pipe',

    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -pipe'

    ccversion='', gccversion='3.3.5 20050117 (prerelease) (SUSE Linux)', gccosandvers=''

    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234

    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12

    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8

    alignbytes=4, prototype=define

 Linker and Libraries:

    ld='cc', ldflags =''

    libpth=/lib /usr/lib /usr/local/lib

    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

    libc=, so=so, useshrplib=true, libperl=libperl.so

   gnulibc_version='2.3.4'

 Dynamic Linking:

    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE'

    cccdlflags='-fPIC', lddlflags='-shared'

 

 

Characteristics of this binary (from libperl):

 Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT

 Built under linux

 Compiled at Mar 19 2005 17:34:48

 @INC:

    /usr/lib/perl5/5.8.6/i586-linux-thread-multi

    /usr/lib/perl5/5.8.6

    /usr/lib/perl5/site_perl/5.8.6/i586-linux-thread-multi

    /usr/lib/perl5/site_perl/5.8.6

    /usr/lib/perl5/site_perl

    /usr/lib/perl5/vendor_perl/5.8.6/i586-linux-thread-multi

    /usr/lib/perl5/vendor_perl/5.8.6

    /usr/lib/perl5/vendor_perl

    .

xk@linux:~/work>

-V:name:打印出指定name的配置变量的配置信息。

xk@linux:~/work> perl -V:osvers

osvers='2.6.9';

xk@linux:~/work>

-w:显示警告信息。

[xk@xk work]$ cat test.pl

#!/bin/perl

$text = "test";

$text += 1;

print $text;

[xk@xk work]$ perl -w test.pl

Argument "test" isn't numeric in addition (+) at test.pl line 3.

1[xk@xk work]$ perl test.pl

1[xk@xk work]$

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
寒假【perl语言学习脚本】13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8发布时间:2022-07-22
下一篇:
perl dancer + net::ssh2监控服务器性能发布时间:2022-07-22
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap