| ?????? | eval |
| ?????? | eval(string) |
| ??? | ??string????Perl?????? ????????????$@?????????????$@???????????? |
| ???? | $print = "print (\"hello,world\\n\");"; eval ($print); |
| ?????? | hello, world |
| ?????? | system |
| ?????? | system(list) |
| ??? | list???????????????????????????? system???????????????????????????????????????????????????????? |
| ???? | @proglist = ("echo", "hello,world!"); system(@proglist); |
| ?????? | hello, world! |
| ?????? | fork |
| ?????? | procid = fork(); |
| ??? | ?????????????????--????????????--????????????????????????????????????????????ID??? |
| ???? | $retval = fork(); if ($retval == 0) { # this is the child process exit; # this terminates the child process } else { # this is the parent process } |
| ?????? | ?? |
| ?????? | pipe |
| ?????? | pipe (infile, outfile); |
| ??? | ??fork????????????????????????????????outfile???????????????????infile???????????????s 1??????pipe 2????fork??????????????????? 3???????????infile??????????outfile |
| ???? | pipe (INPUT, OUTPUT); $retval = fork(); if ($retval != 0) { # this is the parent process close (INPUT); print ("Enter a line of input:\n"); $line = <STDIN>; print OUTPUT ($line); } else { # this is the child process close (OUTPUT); $line = <INPUT>; print ($line); exit (0); } |
| ?????? | $ program Enter a line of input: Here is a test line Here is a test line $ |
| ?????? | exec |
| ?????? | exec (list); |
| ??? | ??system???????????????????????????????????fork???????fork???????????????????exec???????????? |
| ???? | |
| ?????? |
| ?????? | syscall |
| ?????? | syscall (list); |
| ??? | ????????????list??????????????????????????????? ?????????????????????C????????(type int)?????????????????????UNIX???????Perl????? ???syscall??????????syscall.pl?????? require ("syscall.ph"); |
| ???? | |
| ?????? |
| ?????? | die |
| ?????? | die (message); |
| ??? | ?????????STDERR????????????message?????????????????????????????????????????????????????????????? |
| ???? | die ("Cannot open input file"); |
| ?????? | Cannot open input file at myprog line 6. |
| ?????? | warn |
| ?????? | warn (message); |
| ??? | ??die??????????????????? |
| ???? | warn("Danger! Danger!\n"); |
| ?????? | Danger! Danger! |
| ?????? | exit |
| ?????? | exit (retcode); |
| ??? | ????????????????? |
| ???? | exit(2); |
| ?????? | ?? |
| ?????? | kill |
| ?????? | kill (signal, proclist); |
| ??? | ??????????????? signal??????????????9???????? proclist?????ID??????kill??UNIX?????? |
| ???? | |
| ?????? |
| ?????? | sleep |
| ?????? | sleep (time); |
| ??? | ???????????????time??????????????????????????????? |
| ???? | sleep (5); |
| ?????? | ?? |
| ?????? | wait |
| ?????? | procid = wait(); |
| ??? | ??????????????????????? ??????????????????????ID??????????????????-1?? |
| ???? | |
| ?????? |
| ?????? | waitpid |
| ?????? | waitpid (procid, waitflag); |
| ??? | ????????????????????????????procid?????????ID |
| ???? | $procid = fork(); if ($procid == 0) { # this is the child process print ("this line is printed first\n"); exit(0); } else { # this is the parent process waitpid ($procid, 0); print ("this line is printed last\n"); } |
| ?????? | $ program this line is printed first this line is printed last $ |
| ?????? | caller |
| ?????? | subinfo = caller(); |
| ??? | ????????????????????????Perl Debugger?? ??????????????? 1???????????? 2????????????? 3??????????? |
| ???? | |
| ?????? |
| ?????? | chroot |
| ?????? | chroot (dir); |
| ??? | ???????????????chroot?????? |
| ???? | |
| ?????? |
| ?????? | local |
| ?????? | local($variable); |
| ??? | ??????(??????????????)??????????????????????????????????????????????????????? ???????????????????????????????????????????? |
| ???? | |
| ?????? |
| ?????? | times |
| ?????? | timelist = times |
| ??? | ??????????????????????????? ???????????????????? 1???????????????? 2??????????????? 3????????????????? 4???????????????? |
| ???? | |
| ?????? |
| ?????? | sin |
| ?????? | retval = sin (value); |
| ??? | ???????????? |
| ?????? | cos |
| ?????? | retval = cos (value); |
| ??? | ???????????? |
| ?????? | atan2 |
| ?????? | retval = atan2 (value1, value2); |
| ??? | ????????value1????value2?????arctan???????????????-PI~PI?? |
| ??????? ???????????????? |
sub degrees_to_radians { local ($degrees) = @_; local ($radians);11: $radians = atan2(1,1) * $degrees / 45; } |
| ?????? | sqrt |
| ?????? | retval = sqrt (value); |
| ??? | ???????????value???????? |
| ?????? | exp |
| ?????? | retval = exp (value); |
| ??? | ????e??value???? |
| ?????? | log |
| ?????? | retval = log (value); |
| ??? | ??e????????????? |
| ?????? | abs |
| ?????? | retval = abs (value); |
| ??? | ???????????(Perl 4?????) |
| ?????? | rand |
| ?????? | retval = rand (num); |
| ??? | ???????????????0??????num??????????????? |
| ?????? | srand |
| ?????? | srand (value); |
| ??? | ??????????????????????????rand????????? |
| ?????? | index |
| ?????? | position = index (string, substring, position); |
| ??? | ???????substring???????string??????????????????-1??????position?????????????????????????????????????????? |
| ?????? | rindex |
| ?????? | position = rindex (string, substring, position); |
| ??? | ??index?????????????????? |
| ?????? | length |
| ?????? | num = length (string); |
| ??? | ????????????????????????????????? |
| ?????? | pos |
| ?????? | offset = pos(string); |
| ??? | ?????????????????? |
| ?????? | substr |
| ?????? | substr (expr, skipchars, length) |
| ??? | ???????????????????????????expr???????????skipchars????????????????skipchars??????????????????????0????????????length????????????????????????????? ?????????????????????expr??????????????????????????????????????????I?? |
| ?????? | study |
| ?????? | study (scalar); |
| ??? | ??????????????????????????????????????????????? |
| ?????? | lc uc |
| ?????? | retval = lc(string); retval = uc(string); |
| ??? | ???????????????/??????? |
| ?????? | lcfirst ucfirst |
| ?????? | retval = lcfirst(string); retval = ucfirst(string); |
| ??? | ???????????????/???? |
| ?????? | quotameta |
| ?????? | newstring = quotemeta(oldstring); |
| ??? | ????????????????????(\)?? ??? ?? $string = quotemeta($string); ?????$string =~ s/(\W)/\\$1/g; ???????????????????????????????????????????????? |
| ?????? | join |
| ?????? | join (joinstr, list); |
| ??? | ?????????(????)??????????????????????????????????joinstr?? |
| ?????? | sprintf |
| ?????? | sprintf (string, fields); |
| ??? | ??printf????????????????????????????????????????????? |
| ???? | $num = 26; $outstr = sprintf("%d = %x hexadecimal or %o octal\n",$num, $num, $num); print ($outstr); |
| ?????? | 26 = 1a hexadecimal or 32 octal |
| ?????? | chop |
| ?????? | $lastchar = chop (var); |
| ??? | var??????????????var????????????????????????????$lastchar????var?????/????????????????????????????????????????????????????$lastchar?? |
| ?????? | chomp |
| ?????? | result = chomp(var); |
| ??? | ????????????????????????????????????????????$/????????????????????????????????????????????? |
| ?????? | crypt |
| ?????? | result = crypt (original, salt); |
| ??? | ??DES?????????????original????????????????salt??????????????????????????DES????????????????????????????? |
| ?????? | hex |
| ?????? | decnum = hex (hexnum); |
| ??? | ???????????(????????)????????????? |
| ?????? | int |
| ?????? | intnum = int (floatnum); |
| ??? | ????????????????????????????? |
| ?????? | oct |
| ?????? | decnum = oct (octnum); |
| ??? | ?????????(????????)???????????("0x.."???)????????????? |
| ?????? | ord |
| ?????? | asciival = ord (char); |
| ??? | ????????????ASCII?????PASCAL?????????????? |
| ?????? | chr |
| ?????? | $char = chr (asciival); |
| ??? | ????ASCII?????????????PASCAL?????????????? |
| ?????? | pack | ||||||||||||||||||||
| ?????? | formatstr = pack(packformat, list); | ||||||||||||||||||||
| ??? | ???????????????????????????????C?????????????????????????????????????????packformat????????????????????????????????????????????????????tab????????pack?????? ??????a??A??@?????????????????????????????? $twoints = pack ("i2", 103, 241); ???????????????????????*???? $manyints = pack ("i*", 14, 26, 11, 83); ????a??A???????????????????????????????????????????? $strings = pack ("a6" x 2, "test1", "test2"); ???@???????????????????????????????????????????????????????????????????(null)????? $output = pack ("a @6 a", "test", "test2"); pack??????????????????????C?????????????????C???????????????????(null)????????????????????????????? $Cstring = pack ("ax", $mystring); ?????????????C?????????????????
|
| ?????? | ???? |
| a | ??????(null)?????????? |
| A | ???????????? |
| b | ????????? |
| B | ????????? |
| c | ??????????????-128~127?? |
| C | ?????????????8?? |
| d | ?????????? |
| f | ??????????? |
| h | ?????????????????? |
| H | ?????????????????? |
| i | ?????????? |
| I | ????????? |
| l | ??????????? |
| L | ?????????? |
| n | ??????????? |
| N | ?????????? |
| p | ???????? |
| s | ??????????? |
| S | ?????????? |
| u | ?????uuencode??? |
| v | VAX??????? |
| V | VAX?????? |
| x | ???????? |
| X | ?????????? |
| @ | ??????(null)??? |
| ?????? | unpack |
| ?????? | @list = unpack (packformat, formatstr); |
| ??? | unpack??pack??????????????????????????????Perl?????????????????pack????????????????????????A?????????????????????Perl????????????????????????x????????????@????????????????????@4?????4?????????L???@??X??????????
$longrightint = unpack ("@* X4 L", $packstring); ??????????????????????????????????????L?????uuencode????????????? 1 : #!/usr/local/bin/perl????pack??unpack????uuencode??????????????????UNIX??uuencode??uudecode?????????????????????????????????uudecode????pack??????????????????????????????????????????UNIX??uuencode???????? |
| ?????? | vec |
| ?????? | retval = vec (vector, index, bits); |
| ??? | ??????vec?????(vector)???????????????vector??????????(?)???????A????????????????????????????????????????????????????????????????????index??????????????????????????0????????????????????????????????????????????????????????bits?????????????????1,2,4,8,16??32?? |
| ???? |
1 : #!/usr/local/bin/perl 2 : 3 : $vector = pack ("B*", "11010011"); 4 : $val1 = vec ($vector, 0, 4); 5 : $val2 = vec ($vector, 1, 4); 6 : print ("high-to-low order values: $val1 and $val2\n"); 7 : $vector = pack ("b*", "11010011"); 8 : $val1 = vec ($vector, 0, 4); 9 : $val2 = vec ($vector, 1, 4); 10: print ("low-to-high order values: $val1 and $val2\n"); |
| ??? | high-to-low order values: 3 and 13 low-to-high order values: 11 and 12 |
| ?????? | defined |
| ?????? | retval = defined (expr); |
| ??? | ????????????????????????????????????????expr???????????????????????????? ???????????????????? |
| ?????? | undef |
| ?????? | retval = undef (expr); |
| ??? | ???????????????????????????????????????????????????????????????????? |
| ?????? | grep |
| ?????? | @foundlist = grep (pattern, @searchlist); |
| ??? | ???????UNIX????????????grep??????????????????????????????pattern????????????????????????????? |
| ???? | @list = ("This", "is", "a", "test"); @foundlist = grep(/^[tT]/, @list); |
| ??? | @foundlist = ("This", "test"); |
| ?????? | splice |
| ?????? | @retval = splice (@array, slipelements, length, @newlist); |
| ??? | ????????????????????????????????????I?????????skipelements????????????????????length????I?????????newlist?????????????????newlist????????length???????????????????????????????????????length=0?????????????????????????????? splice (@array, -1, 0, "Hello"); ????????????????????newlist??????????????????????????length????????skipelements?????????????????????????????????splice (@array, -1);??????????????????????????? |
| ?????? | shift |
| ?????? | element = shift (@arrayvar); |
| ??? | ????????????????????????????????????????????????????@ARGV???????? |
| ?????? | unshift |
| ?????? | count = unshift (@arrayver, elements); |
| ??? | ??????shift??????????arrayvar???????????????????????????(??)???????????splice (@array, 0, 0, elements); |
| ?????? | push |
| ?????? | push (@arrayvar, elements); |
| ??? | ???????????????????????????slice (@array, @array, 0, elements); |
| ?????? | pop |
| ?????? | element = pop (@arrayvar); |
| ??? | ??push??????????????????????????????????????????????????????????(?????)?? |
| ?????? | split |
| ?????? | @list = split (pattern, string, maxlength); |
| ??? | ????????????????????????????pattern?????????????????pattern????????????????maxlength??????????????????????????? |
| ?????? | sort |
| ?????? | @sorted = sort (@list); |
| ??? | ???????????????? |
| ?????? | reverse |
| ?????? | @reversed = reverse (@list); |
| ??? | ???????????????? |
| ?????? | map |
| ?????? | @resultlist = map (expr, @list); |
| ??? | ???????Perl5?????????????????????????expr?????????????????????????????????????????expr????????$_??????????? |
| ???? | 1??@list = (100, 200, 300); @results = map ($_+1, @list); 2??@results = map (&mysub($_), @list); |
| ??? | 1??(101, 201, 301) 2???? |
| ?????? | wantarray |
| ?????? | result = wantarray(); |
| ??? | Perl??????????????????????????????????????????????chop??????????????????????????????????????????????????????????????????????(??)??????????(??)?? |
| ???? |
1 : #!/usr/local/bin/perl 2 : 3 : @array = &mysub(); 4 : $scalar = &mysub(); 5 : 6 : sub mysub { 7 : if (wantarray()) { 8 : print ("true\n"); 9 : } else { 10: print ("false\n"); 11: } 12: } |
| ??? | $program true false $ |
| ?????? | keys |
| ?????? | @list = keys (%assoc_array); |
| ??? | ????????????????????? |
| ?????? | values |
| ?????? | @list = values (%assoc_array); |
| ??? | ???????????????????? |
| ?????? | each |
| ?????? | @pair = each (%assoc_array); |
| ??? | ??????????????--?????????????????????????????????????????????????? |
| ?????? | delete |
| ?????? | element = delete (assoc_array_item); |
| ??? | ?????????????????????????????????? |
| ???? | %array = ("foo", 26, "bar", 17"); $retval = delete ($array{"foo"}); |
| ??? | $retval = 26; |
| ?????? | exists |
| ?????? | result = exists (element); |
| ??? | ??Perl5???????????????????????????????????????(??)???????????(??)?? |
| ???? | $result = exists ($myarray{$mykey}); |