CONTENT
  • CHANGES
Szukaj
counter

#top perl


perl - Practical Extraction and Report Language

Powiązane:
awk, perl

SYNOPSIS
perl [ -sTtuUWX ] [ -hv ] [ -V[:configvar] ] [ -cw ] [ -d[t][:debugger] ] [ -D[number/list] ] [ -pna ] [ -Fpattern ] [ -l[octal] ] [ -0[octal/hexadecimal] ] [ -Idir ] [ -m[-]module ] [ -M[-]’module...’ ] [ -f ] [ -C [number/list] ] [ -P ] [ -S ] [ -x[dir] ] [ -i[extension] ] [ -e ’command’ ] [ -- ] [ programfile ] [ argument ]...


DESCRIPTION



OPTIONS
-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
don't do $sitelib/sitecustomize.pl at startup

-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



EXAMPLES
perl -MMIME::Base64 -e ' print(encode_base64("test")."\n"); '

/usr/bin/perl /usr/share/logwatch/scripts/shared/applystddate
Can't locate Logwatch.pm in @INC (@INC contains: /usr/share/logwatch /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/share/logwatch/scripts/shared/applystddate line 13.
/usr/bin/perl -I/usr/share/logwatch/lib /usr/share/logwatch/scripts/shared/applystddate

message with polish locale
LANG=pl_PL.UTF-8
perl -e 'use POSIX qw(strftime); print(strftime("%a, %d %b %Y %H:%M:%S +0200",localtime(time()))."\n")'
Rezultat:
śro, 22 maj 2013 00:00:00 +0200

message with english locale
perl -e 'use POSIX qw(strftime); use POSIX qw(locale_h); setlocale(LC_TIME, "en_US.UTF-8"); print(strftime("%a, %d %b %Y %H:%M:%S +0200",localtime(time()))."\n")'
Rezultat:
Wed, 22 May 2013 00:00:00 +0200

HTTP HEADER: Date:
perl -e 'use POSIX qw(strftime); use POSIX qw(locale_h); setlocale(LC_TIME, "en_US.UTF-8"); print(strftime("%a, %d %b %Y %H:%M:%S GMT",localtime(time()-3600))."\n")'
Rezultat:
Date: Mon, 09 Dec 2013 17:36:10 GMT

reading file like tail: while(1) { while($line=<FH>) { ... } }
perl -e ' if(open($fpr,"/home/user/tmp/ola")) { while (1) { while ($line=<$fpr>) { $line=~s,[\r\n]*$,,g; print("line=|$line|\n"); } seek($fpr, 0, 1); } close($fpr); } else { print("Unable open file: ola, Reason $!\n"); } '




Zmodyfikowany ostatnio: 2014/07/16 12:22:21 (9 lat temu), textsize: 5,88 kB, htmlsize: 7,20 kB

Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników