gitlab-pygments.rb 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/README.md +91 -0
- data/Rakefile +78 -0
- data/bench.rb +22 -0
- data/cache-lexers.rb +8 -0
- data/lexers +0 -0
- data/lib/pygments/lexer.rb +148 -0
- data/lib/pygments/mentos.py +344 -0
- data/lib/pygments/popen.rb +389 -0
- data/lib/pygments/version.rb +3 -0
- data/lib/pygments.rb +8 -0
- data/pygments.rb.gemspec +24 -0
- data/test/test_data.c +2581 -0
- data/test/test_data.py +514 -0
- data/test/test_data_generated +2582 -0
- data/test/test_pygments.rb +276 -0
- data/vendor/custom_formatters/gitlab.py +171 -0
- data/vendor/custom_lexers/github.py +362 -0
- data/vendor/pygments-main/AUTHORS +115 -0
- data/vendor/pygments-main/CHANGES +762 -0
- data/vendor/pygments-main/LICENSE +25 -0
- data/vendor/pygments-main/MANIFEST.in +6 -0
- data/vendor/pygments-main/Makefile +59 -0
- data/vendor/pygments-main/REVISION +1 -0
- data/vendor/pygments-main/TODO +15 -0
- data/vendor/pygments-main/docs/generate.py +472 -0
- data/vendor/pygments-main/docs/pygmentize.1 +94 -0
- data/vendor/pygments-main/docs/src/api.txt +270 -0
- data/vendor/pygments-main/docs/src/authors.txt +5 -0
- data/vendor/pygments-main/docs/src/changelog.txt +5 -0
- data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
- data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
- data/vendor/pygments-main/docs/src/filters.txt +42 -0
- data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
- data/vendor/pygments-main/docs/src/formatters.txt +48 -0
- data/vendor/pygments-main/docs/src/index.txt +69 -0
- data/vendor/pygments-main/docs/src/installation.txt +71 -0
- data/vendor/pygments-main/docs/src/integrate.txt +43 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -0
- data/vendor/pygments-main/docs/src/lexers.txt +67 -0
- data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
- data/vendor/pygments-main/docs/src/plugins.txt +93 -0
- data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
- data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
- data/vendor/pygments-main/docs/src/styles.txt +143 -0
- data/vendor/pygments-main/docs/src/tokens.txt +349 -0
- data/vendor/pygments-main/docs/src/unicode.txt +49 -0
- data/vendor/pygments-main/external/markdown-processor.py +67 -0
- data/vendor/pygments-main/external/moin-parser.py +112 -0
- data/vendor/pygments-main/external/pygments.bashcomp +38 -0
- data/vendor/pygments-main/external/rst-directive-old.py +77 -0
- data/vendor/pygments-main/external/rst-directive.py +83 -0
- data/vendor/pygments-main/ez_setup.py +276 -0
- data/vendor/pygments-main/pygmentize +7 -0
- data/vendor/pygments-main/pygments/__init__.py +91 -0
- data/vendor/pygments-main/pygments/cmdline.py +433 -0
- data/vendor/pygments-main/pygments/console.py +74 -0
- data/vendor/pygments-main/pygments/filter.py +74 -0
- data/vendor/pygments-main/pygments/filters/__init__.py +357 -0
- data/vendor/pygments-main/pygments/formatter.py +92 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
- data/vendor/pygments-main/pygments/formatters/html.py +750 -0
- data/vendor/pygments-main/pygments/formatters/img.py +553 -0
- data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
- data/vendor/pygments-main/pygments/formatters/other.py +117 -0
- data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
- data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
- data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
- data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
- data/vendor/pygments-main/pygments/lexer.py +697 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +229 -0
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
- data/vendor/pygments-main/pygments/lexers/github.py +362 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +361 -0
- data/vendor/pygments-main/pygments/lexers/special.py +100 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +1631 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
- data/vendor/pygments-main/pygments/lexers/web.py +2864 -0
- data/vendor/pygments-main/pygments/plugin.py +74 -0
- data/vendor/pygments-main/pygments/scanner.py +104 -0
- data/vendor/pygments-main/pygments/style.py +117 -0
- data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
- data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
- data/vendor/pygments-main/pygments/styles/borland.py +51 -0
- data/vendor/pygments-main/pygments/styles/bw.py +49 -0
- data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
- data/vendor/pygments-main/pygments/styles/default.py +73 -0
- data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
- data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
- data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
- data/vendor/pygments-main/pygments/styles/manni.py +75 -0
- data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
- data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
- data/vendor/pygments-main/pygments/styles/native.py +65 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
- data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
- data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
- data/vendor/pygments-main/pygments/styles/tango.py +141 -0
- data/vendor/pygments-main/pygments/styles/trac.py +63 -0
- data/vendor/pygments-main/pygments/styles/vim.py +63 -0
- data/vendor/pygments-main/pygments/styles/vs.py +38 -0
- data/vendor/pygments-main/pygments/token.py +195 -0
- data/vendor/pygments-main/pygments/unistring.py +130 -0
- data/vendor/pygments-main/pygments/util.py +232 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -0
- data/vendor/pygments-main/scripts/epydoc.css +280 -0
- data/vendor/pygments-main/scripts/find_codetags.py +205 -0
- data/vendor/pygments-main/scripts/find_error.py +171 -0
- data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
- data/vendor/pygments-main/scripts/pylintrc +301 -0
- data/vendor/pygments-main/scripts/reindent.py +291 -0
- data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
- data/vendor/pygments-main/setup.cfg +6 -0
- data/vendor/pygments-main/setup.py +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
- data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
- data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
- data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
- data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
- data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
- data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
- data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
- data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
- data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
- data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
- data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
- data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
- data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
- data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
- data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
- data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
- data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
- data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
- data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
- data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
- data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
- data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
- data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
- data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
- data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
- data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +40 -0
- data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
- data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
- data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
- data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
- data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
- data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
- data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
- data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
- data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
- data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
- data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
- data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
- data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
- data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
- data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
- data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
- data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
- data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
- data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
- data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
- data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
- data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
- data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
- data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
- data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
- data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
- data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
- data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
- data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
- data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
- data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
- data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
- data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
- data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
- data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
- data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
- data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
- data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
- data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
- data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
- data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
- data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
- data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
- data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
- data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +27 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
- data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
- data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
- data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
- data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
- data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
- data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +25 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
- data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
- data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
- data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
- data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
- data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
- data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
- data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
- data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
- data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
- data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
- data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
- data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
- data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
- data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
- data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
- data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
- data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
- data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
- data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
- data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
- data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
- data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
- data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
- data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
- data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
- data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
- data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
- data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +119 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
- data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
- data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
- data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
- data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
- data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
- data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
- data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
- data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
- data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
- data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
- data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
- data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
- data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
- data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
- data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
- data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
- data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
- data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
- data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
- data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
- data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
- data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
- data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
- data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
- data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
- data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
- data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
- data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
- data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
- data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
- data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
- data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
- data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
- data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
- data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
- data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
- data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -0
- data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
- data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
- data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
- data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
- data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
- data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
- data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
- data/vendor/pygments-main/tests/old_run.py +138 -0
- data/vendor/pygments-main/tests/run.py +48 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/test_basic_api.py +294 -0
- data/vendor/pygments-main/tests/test_clexer.py +31 -0
- data/vendor/pygments-main/tests/test_cmdline.py +105 -0
- data/vendor/pygments-main/tests/test_examplefiles.py +97 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
- data/vendor/pygments-main/tests/test_perllexer.py +137 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
- data/vendor/pygments-main/tests/test_token.py +46 -0
- data/vendor/pygments-main/tests/test_using_api.py +40 -0
- data/vendor/pygments-main/tests/test_util.py +116 -0
- data/vendor/simplejson/.gitignore +10 -0
- data/vendor/simplejson/.travis.yml +5 -0
- data/vendor/simplejson/CHANGES.txt +291 -0
- data/vendor/simplejson/LICENSE.txt +19 -0
- data/vendor/simplejson/MANIFEST.in +5 -0
- data/vendor/simplejson/README.rst +19 -0
- data/vendor/simplejson/conf.py +179 -0
- data/vendor/simplejson/index.rst +628 -0
- data/vendor/simplejson/scripts/make_docs.py +18 -0
- data/vendor/simplejson/setup.py +104 -0
- data/vendor/simplejson/simplejson/__init__.py +510 -0
- data/vendor/simplejson/simplejson/_speedups.c +2745 -0
- data/vendor/simplejson/simplejson/decoder.py +425 -0
- data/vendor/simplejson/simplejson/encoder.py +567 -0
- data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
- data/vendor/simplejson/simplejson/scanner.py +77 -0
- data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
- data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
- data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
- data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
- data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
- data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
- data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
- data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
- data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
- data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
- data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
- data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
- data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
- data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
- data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
- data/vendor/simplejson/simplejson/tool.py +39 -0
- metadata +492 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
#! /usr/bin/env perl
|
2
|
+
|
3
|
+
use strict;
|
4
|
+
use warnings;
|
5
|
+
|
6
|
+
# common delimiters
|
7
|
+
print "a: ";
|
8
|
+
my $a = "foo";
|
9
|
+
print $a, " - ";
|
10
|
+
$a =~ s/foo/bar/;
|
11
|
+
print $a, "\n";
|
12
|
+
|
13
|
+
print "b: ";
|
14
|
+
my $b = "foo";
|
15
|
+
print $b, " - ";
|
16
|
+
$b =~ s!foo!bar!;
|
17
|
+
print $b, "\n";
|
18
|
+
|
19
|
+
print "c: ";
|
20
|
+
my $c = "foo";
|
21
|
+
print $c, " - ";
|
22
|
+
$c =~ s@foo@bar@;
|
23
|
+
print $c, "\n";
|
24
|
+
|
25
|
+
print "d: ";
|
26
|
+
my $d = "foo";
|
27
|
+
print $d, " - ";
|
28
|
+
$d =~ s\foo\bar\;
|
29
|
+
print $d, "\n";
|
30
|
+
|
31
|
+
print "\n";
|
32
|
+
|
33
|
+
# balanced delimiters
|
34
|
+
print "e: ";
|
35
|
+
my $e = "foo";
|
36
|
+
print $e, " - ";
|
37
|
+
$e =~ s{foo}{bar};
|
38
|
+
print $e, "\n";
|
39
|
+
|
40
|
+
print "f: ";
|
41
|
+
my $f = "foo";
|
42
|
+
print $f, " - ";
|
43
|
+
$f =~ s(foo)(bar);
|
44
|
+
print $f, "\n";
|
45
|
+
|
46
|
+
print "g: ";
|
47
|
+
my $g = "foo";
|
48
|
+
print $g, " - ";
|
49
|
+
$g =~ s<foo><bar>;
|
50
|
+
print $g, "\n";
|
51
|
+
|
52
|
+
print "h: ";
|
53
|
+
my $h = "foo";
|
54
|
+
print $h, " - ";
|
55
|
+
$h =~ s[foo][bar];
|
56
|
+
print $h, "\n";
|
57
|
+
|
58
|
+
print "\n";
|
59
|
+
|
60
|
+
# balanced delimiters with whitespace
|
61
|
+
print "i: ";
|
62
|
+
my $i = "foo";
|
63
|
+
print $i, " - ";
|
64
|
+
$i =~ s{foo} {bar};
|
65
|
+
print $i, "\n";
|
66
|
+
|
67
|
+
print "j: ";
|
68
|
+
my $j = "foo";
|
69
|
+
print $j, " - ";
|
70
|
+
$j =~ s<foo> <bar>;
|
71
|
+
print $j, "\n";
|
72
|
+
|
73
|
+
print "k: ";
|
74
|
+
my $k = "foo";
|
75
|
+
print $k, " - ";
|
76
|
+
$k =~
|
77
|
+
s(foo)
|
78
|
+
|
79
|
+
(bar);
|
80
|
+
print $k, "\n";
|
81
|
+
|
82
|
+
print "\n";
|
83
|
+
|
84
|
+
# mixed delimiters
|
85
|
+
print "l: ";
|
86
|
+
my $l = "foo";
|
87
|
+
print $l, " - ";
|
88
|
+
$l =~ s{foo} <bar>;
|
89
|
+
print $l, "\n";
|
90
|
+
|
91
|
+
print "m: ";
|
92
|
+
my $m = "foo";
|
93
|
+
print $m, " - ";
|
94
|
+
$m =~ s(foo) !bar!;
|
95
|
+
print $m, "\n";
|
96
|
+
|
97
|
+
print "n: ";
|
98
|
+
my $n = "foo";
|
99
|
+
print $n, " - ";
|
100
|
+
$n =~ s[foo] $bar$;
|
101
|
+
print $n, "\n";
|
102
|
+
|
103
|
+
print "\n";
|
104
|
+
|
105
|
+
# /x modifier
|
106
|
+
print "o: ";
|
107
|
+
my $o = "foo";
|
108
|
+
print $o, " - ";
|
109
|
+
$o =~ s{
|
110
|
+
foo
|
111
|
+
} {bar}x;
|
112
|
+
print $o, "\n";
|
113
|
+
|
114
|
+
print "p: ";
|
115
|
+
my $p = "foo";
|
116
|
+
print $p, " - ";
|
117
|
+
$p =~ s%
|
118
|
+
foo
|
119
|
+
%bar%x;
|
120
|
+
print $p, "\n";
|
@@ -0,0 +1,856 @@
|
|
1
|
+
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
|
2
|
+
.\"
|
3
|
+
.\" Standard preamble:
|
4
|
+
.\" ========================================================================
|
5
|
+
.de Sh \" Subsection heading
|
6
|
+
.br
|
7
|
+
.if t .Sp
|
8
|
+
.ne 5
|
9
|
+
.PP
|
10
|
+
\fB\\$1\fR
|
11
|
+
.PP
|
12
|
+
..
|
13
|
+
.de Sp \" Vertical space (when we can't use .PP)
|
14
|
+
.if t .sp .5v
|
15
|
+
.if n .sp
|
16
|
+
..
|
17
|
+
.de Vb \" Begin verbatim text
|
18
|
+
.ft CW
|
19
|
+
.nf
|
20
|
+
.ne \\$1
|
21
|
+
..
|
22
|
+
.de Ve \" End verbatim text
|
23
|
+
.ft R
|
24
|
+
.fi
|
25
|
+
..
|
26
|
+
.\" Set up some character translations and predefined strings. \*(-- will
|
27
|
+
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
28
|
+
.\" double quote, and \*(R" will give a right double quote. | will give a
|
29
|
+
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
|
30
|
+
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
|
31
|
+
.\" expand to `' in nroff, nothing in troff, for use with C<>.
|
32
|
+
.tr \(*W-|\(bv\*(Tr
|
33
|
+
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
34
|
+
.ie n \{\
|
35
|
+
. ds -- \(*W-
|
36
|
+
. ds PI pi
|
37
|
+
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
38
|
+
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
39
|
+
. ds L" ""
|
40
|
+
. ds R" ""
|
41
|
+
. ds C` ""
|
42
|
+
. ds C' ""
|
43
|
+
'br\}
|
44
|
+
.el\{\
|
45
|
+
. ds -- \|\(em\|
|
46
|
+
. ds PI \(*p
|
47
|
+
. ds L" ``
|
48
|
+
. ds R" ''
|
49
|
+
'br\}
|
50
|
+
.\"
|
51
|
+
.\" If the F register is turned on, we'll generate index entries on stderr for
|
52
|
+
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
|
53
|
+
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
54
|
+
.\" output yourself in some meaningful fashion.
|
55
|
+
.if \nF \{\
|
56
|
+
. de IX
|
57
|
+
. tm Index:\\$1\t\\n%\t"\\$2"
|
58
|
+
..
|
59
|
+
. nr % 0
|
60
|
+
. rr F
|
61
|
+
.\}
|
62
|
+
.\"
|
63
|
+
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
64
|
+
.\" way too many mistakes in technical documents.
|
65
|
+
.hy 0
|
66
|
+
.if n .na
|
67
|
+
.\"
|
68
|
+
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
69
|
+
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
70
|
+
. \" fudge factors for nroff and troff
|
71
|
+
.if n \{\
|
72
|
+
. ds #H 0
|
73
|
+
. ds #V .8m
|
74
|
+
. ds #F .3m
|
75
|
+
. ds #[ \f1
|
76
|
+
. ds #] \fP
|
77
|
+
.\}
|
78
|
+
.if t \{\
|
79
|
+
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
80
|
+
. ds #V .6m
|
81
|
+
. ds #F 0
|
82
|
+
. ds #[ \&
|
83
|
+
. ds #] \&
|
84
|
+
.\}
|
85
|
+
. \" simple accents for nroff and troff
|
86
|
+
.if n \{\
|
87
|
+
. ds ' \&
|
88
|
+
. ds ` \&
|
89
|
+
. ds ^ \&
|
90
|
+
. ds , \&
|
91
|
+
. ds ~ ~
|
92
|
+
. ds /
|
93
|
+
.\}
|
94
|
+
.if t \{\
|
95
|
+
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
96
|
+
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
97
|
+
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
98
|
+
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
99
|
+
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
100
|
+
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
101
|
+
.\}
|
102
|
+
. \" troff and (daisy-wheel) nroff accents
|
103
|
+
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
104
|
+
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
105
|
+
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
106
|
+
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
107
|
+
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
108
|
+
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
109
|
+
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
110
|
+
.ds ae a\h'-(\w'a'u*4/10)'e
|
111
|
+
.ds Ae A\h'-(\w'A'u*4/10)'E
|
112
|
+
. \" corrections for vroff
|
113
|
+
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
114
|
+
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
115
|
+
. \" for low resolution devices (crt and lpr)
|
116
|
+
.if \n(.H>23 .if \n(.V>19 \
|
117
|
+
\{\
|
118
|
+
. ds : e
|
119
|
+
. ds 8 ss
|
120
|
+
. ds o a
|
121
|
+
. ds d- d\h'-1'\(ga
|
122
|
+
. ds D- D\h'-1'\(hy
|
123
|
+
. ds th \o'bp'
|
124
|
+
. ds Th \o'LP'
|
125
|
+
. ds ae ae
|
126
|
+
. ds Ae AE
|
127
|
+
.\}
|
128
|
+
.rm #[ #] #H #V #F C
|
129
|
+
.\" ========================================================================
|
130
|
+
.\"
|
131
|
+
.IX Title "PERLFUNC 1"
|
132
|
+
.TH PERLFUNC 1 "2006-01-07" "perl v5.8.8" "Perl Programmers Reference Guide"
|
133
|
+
.SH "NAME"
|
134
|
+
.IX Xref "function"
|
135
|
+
perlfunc \- Perl builtin functions
|
136
|
+
.SH "DESCRIPTION"
|
137
|
+
.IX Header "DESCRIPTION"
|
138
|
+
The functions in this section can serve as terms in an expression.
|
139
|
+
They fall into two major categories: list operators and named unary
|
140
|
+
operators. These differ in their precedence relationship with a
|
141
|
+
following comma. (See the precedence table in perlop.) List
|
142
|
+
operators take more than one argument, while unary operators can never
|
143
|
+
take more than one argument. Thus, a comma terminates the argument of
|
144
|
+
a unary operator, but merely separates the arguments of a list
|
145
|
+
operator. A unary operator generally provides a scalar context to its
|
146
|
+
argument, while a list operator may provide either scalar or list
|
147
|
+
contexts for its arguments. If it does both, the scalar arguments will
|
148
|
+
be first, and the list argument will follow. (Note that there can ever
|
149
|
+
be only one such list argument.) For instance, \fIsplice()\fR has three scalar
|
150
|
+
arguments followed by a list, whereas \fIgethostbyname()\fR has four scalar
|
151
|
+
arguments.
|
152
|
+
.PP
|
153
|
+
In the syntax descriptions that follow, list operators that expect a
|
154
|
+
list (and provide list context for the elements of the list) are shown
|
155
|
+
with \s-1LIST\s0 as an argument. Such a list may consist of any combination
|
156
|
+
of scalar arguments or list values; the list values will be included
|
157
|
+
in the list as if each individual element were interpolated at that
|
158
|
+
point in the list, forming a longer single-dimensional list value.
|
159
|
+
Commas should separate elements of the \s-1LIST\s0.
|
160
|
+
.PP
|
161
|
+
Any function in the list below may be used either with or without
|
162
|
+
parentheses around its arguments. (The syntax descriptions omit the
|
163
|
+
parentheses.) If you use the parentheses, the simple (but occasionally
|
164
|
+
surprising) rule is this: It \fIlooks\fR like a function, therefore it \fIis\fR a
|
165
|
+
function, and precedence doesn't matter. Otherwise it's a list
|
166
|
+
operator or unary operator, and precedence does matter. And whitespace
|
167
|
+
between the function and left parenthesis doesn't count\*(--so you need to
|
168
|
+
be careful sometimes:
|
169
|
+
.PP
|
170
|
+
.Vb 5
|
171
|
+
\& print 1+2+4; # Prints 7.
|
172
|
+
\& print(1+2) + 4; # Prints 3.
|
173
|
+
\& print (1+2)+4; # Also prints 3!
|
174
|
+
\& print +(1+2)+4; # Prints 7.
|
175
|
+
\& print ((1+2)+4); # Prints 7.
|
176
|
+
.Ve
|
177
|
+
.PP
|
178
|
+
If you run Perl with the \fB\-w\fR switch it can warn you about this. For
|
179
|
+
example, the third line above produces:
|
180
|
+
.PP
|
181
|
+
.Vb 2
|
182
|
+
\& print (...) interpreted as function at - line 1.
|
183
|
+
\& Useless use of integer addition in void context at - line 1.
|
184
|
+
.Ve
|
185
|
+
.PP
|
186
|
+
A few functions take no arguments at all, and therefore work as neither
|
187
|
+
unary nor list operators. These include such functions as \f(CW\*(C`time\*(C'\fR
|
188
|
+
and \f(CW\*(C`endpwent\*(C'\fR. For example, \f(CW\*(C`time+86_400\*(C'\fR always means
|
189
|
+
\&\f(CW\*(C`time() + 86_400\*(C'\fR.
|
190
|
+
.PP
|
191
|
+
For functions that can be used in either a scalar or list context,
|
192
|
+
nonabortive failure is generally indicated in a scalar context by
|
193
|
+
returning the undefined value, and in a list context by returning the
|
194
|
+
null list.
|
195
|
+
.PP
|
196
|
+
Remember the following important rule: There is \fBno rule\fR that relates
|
197
|
+
the behavior of an expression in list context to its behavior in scalar
|
198
|
+
context, or vice versa. It might do two totally different things.
|
199
|
+
Each operator and function decides which sort of value it would be most
|
200
|
+
appropriate to return in scalar context. Some operators return the
|
201
|
+
length of the list that would have been returned in list context. Some
|
202
|
+
operators return the first value in the list. Some operators return the
|
203
|
+
last value in the list. Some operators return a count of successful
|
204
|
+
operations. In general, they do what you want, unless you want
|
205
|
+
consistency.
|
206
|
+
.IX Xref "context"
|
207
|
+
.PP
|
208
|
+
A named array in scalar context is quite different from what would at
|
209
|
+
first glance appear to be a list in scalar context. You can't get a list
|
210
|
+
like \f(CW\*(C`(1,2,3)\*(C'\fR into being in scalar context, because the compiler knows
|
211
|
+
the context at compile time. It would generate the scalar comma operator
|
212
|
+
there, not the list construction version of the comma. That means it
|
213
|
+
was never a list to start with.
|
214
|
+
.PP
|
215
|
+
In general, functions in Perl that serve as wrappers for system calls
|
216
|
+
of the same name (like \fIchown\fR\|(2), \fIfork\fR\|(2), \fIclosedir\fR\|(2), etc.) all return
|
217
|
+
true when they succeed and \f(CW\*(C`undef\*(C'\fR otherwise, as is usually mentioned
|
218
|
+
in the descriptions below. This is different from the C interfaces,
|
219
|
+
which return \f(CW\*(C`\-1\*(C'\fR on failure. Exceptions to this rule are \f(CW\*(C`wait\*(C'\fR,
|
220
|
+
\&\f(CW\*(C`waitpid\*(C'\fR, and \f(CW\*(C`syscall\*(C'\fR. System calls also set the special \f(CW$!\fR
|
221
|
+
variable on failure. Other functions do not, except accidentally.
|
222
|
+
.Sh "Perl Functions by Category"
|
223
|
+
.IX Xref "function"
|
224
|
+
.IX Subsection "Perl Functions by Category"
|
225
|
+
Here are Perl's functions (including things that look like
|
226
|
+
functions, like some keywords and named operators)
|
227
|
+
arranged by category. Some functions appear in more
|
228
|
+
than one place.
|
229
|
+
.IP "Functions for SCALARs or strings" 4
|
230
|
+
.IX Xref "scalar string character"
|
231
|
+
.IX Item "Functions for SCALARs or strings"
|
232
|
+
\&\f(CW\*(C`chomp\*(C'\fR, \f(CW\*(C`chop\*(C'\fR, \f(CW\*(C`chr\*(C'\fR, \f(CW\*(C`crypt\*(C'\fR, \f(CW\*(C`hex\*(C'\fR, \f(CW\*(C`index\*(C'\fR, \f(CW\*(C`lc\*(C'\fR, \f(CW\*(C`lcfirst\*(C'\fR,
|
233
|
+
\&\f(CW\*(C`length\*(C'\fR, \f(CW\*(C`oct\*(C'\fR, \f(CW\*(C`ord\*(C'\fR, \f(CW\*(C`pack\*(C'\fR, \f(CW\*(C`q/STRING/\*(C'\fR, \f(CW\*(C`qq/STRING/\*(C'\fR, \f(CW\*(C`reverse\*(C'\fR,
|
234
|
+
\&\f(CW\*(C`rindex\*(C'\fR, \f(CW\*(C`sprintf\*(C'\fR, \f(CW\*(C`substr\*(C'\fR, \f(CW\*(C`tr///\*(C'\fR, \f(CW\*(C`uc\*(C'\fR, \f(CW\*(C`ucfirst\*(C'\fR, \f(CW\*(C`y///\*(C'\fR
|
235
|
+
.IP "Regular expressions and pattern matching" 4
|
236
|
+
.IX Xref "regular expression regex regexp"
|
237
|
+
.IX Item "Regular expressions and pattern matching"
|
238
|
+
\&\f(CW\*(C`m//\*(C'\fR, \f(CW\*(C`pos\*(C'\fR, \f(CW\*(C`quotemeta\*(C'\fR, \f(CW\*(C`s///\*(C'\fR, \f(CW\*(C`split\*(C'\fR, \f(CW\*(C`study\*(C'\fR, \f(CW\*(C`qr//\*(C'\fR
|
239
|
+
.IP "Numeric functions" 4
|
240
|
+
.IX Xref "numeric number trigonometric trigonometry"
|
241
|
+
.IX Item "Numeric functions"
|
242
|
+
\&\f(CW\*(C`abs\*(C'\fR, \f(CW\*(C`atan2\*(C'\fR, \f(CW\*(C`cos\*(C'\fR, \f(CW\*(C`exp\*(C'\fR, \f(CW\*(C`hex\*(C'\fR, \f(CW\*(C`int\*(C'\fR, \f(CW\*(C`log\*(C'\fR, \f(CW\*(C`oct\*(C'\fR, \f(CW\*(C`rand\*(C'\fR,
|
243
|
+
\&\f(CW\*(C`sin\*(C'\fR, \f(CW\*(C`sqrt\*(C'\fR, \f(CW\*(C`srand\*(C'\fR
|
244
|
+
.ie n .IP "Functions for real @ARRAYs" 4
|
245
|
+
.el .IP "Functions for real \f(CW@ARRAYs\fR" 4
|
246
|
+
.IX Xref "array"
|
247
|
+
.IX Item "Functions for real @ARRAYs"
|
248
|
+
\&\f(CW\*(C`pop\*(C'\fR, \f(CW\*(C`push\*(C'\fR, \f(CW\*(C`shift\*(C'\fR, \f(CW\*(C`splice\*(C'\fR, \f(CW\*(C`unshift\*(C'\fR
|
249
|
+
.IP "Functions for list data" 4
|
250
|
+
.IX Xref "list"
|
251
|
+
.IX Item "Functions for list data"
|
252
|
+
\&\f(CW\*(C`grep\*(C'\fR, \f(CW\*(C`join\*(C'\fR, \f(CW\*(C`map\*(C'\fR, \f(CW\*(C`qw/STRING/\*(C'\fR, \f(CW\*(C`reverse\*(C'\fR, \f(CW\*(C`sort\*(C'\fR, \f(CW\*(C`unpack\*(C'\fR
|
253
|
+
.ie n .IP "Functions for real %HASHes" 4
|
254
|
+
.el .IP "Functions for real \f(CW%HASHes\fR" 4
|
255
|
+
.IX Xref "hash"
|
256
|
+
.IX Item "Functions for real %HASHes"
|
257
|
+
\&\f(CW\*(C`delete\*(C'\fR, \f(CW\*(C`each\*(C'\fR, \f(CW\*(C`exists\*(C'\fR, \f(CW\*(C`keys\*(C'\fR, \f(CW\*(C`values\*(C'\fR
|
258
|
+
.IP "Input and output functions" 4
|
259
|
+
.IX Xref "I O input output dbm"
|
260
|
+
.IX Item "Input and output functions"
|
261
|
+
\&\f(CW\*(C`binmode\*(C'\fR, \f(CW\*(C`close\*(C'\fR, \f(CW\*(C`closedir\*(C'\fR, \f(CW\*(C`dbmclose\*(C'\fR, \f(CW\*(C`dbmopen\*(C'\fR, \f(CW\*(C`die\*(C'\fR, \f(CW\*(C`eof\*(C'\fR,
|
262
|
+
\&\f(CW\*(C`fileno\*(C'\fR, \f(CW\*(C`flock\*(C'\fR, \f(CW\*(C`format\*(C'\fR, \f(CW\*(C`getc\*(C'\fR, \f(CW\*(C`print\*(C'\fR, \f(CW\*(C`printf\*(C'\fR, \f(CW\*(C`read\*(C'\fR,
|
263
|
+
\&\f(CW\*(C`readdir\*(C'\fR, \f(CW\*(C`rewinddir\*(C'\fR, \f(CW\*(C`seek\*(C'\fR, \f(CW\*(C`seekdir\*(C'\fR, \f(CW\*(C`select\*(C'\fR, \f(CW\*(C`syscall\*(C'\fR,
|
264
|
+
\&\f(CW\*(C`sysread\*(C'\fR, \f(CW\*(C`sysseek\*(C'\fR, \f(CW\*(C`syswrite\*(C'\fR, \f(CW\*(C`tell\*(C'\fR, \f(CW\*(C`telldir\*(C'\fR, \f(CW\*(C`truncate\*(C'\fR,
|
265
|
+
\&\f(CW\*(C`warn\*(C'\fR, \f(CW\*(C`write\*(C'\fR
|
266
|
+
.IP "Functions for fixed length data or records" 4
|
267
|
+
.IX Item "Functions for fixed length data or records"
|
268
|
+
\&\f(CW\*(C`pack\*(C'\fR, \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`syscall\*(C'\fR, \f(CW\*(C`sysread\*(C'\fR, \f(CW\*(C`syswrite\*(C'\fR, \f(CW\*(C`unpack\*(C'\fR, \f(CW\*(C`vec\*(C'\fR
|
269
|
+
.IP "Functions for filehandles, files, or directories" 4
|
270
|
+
.IX Xref "file filehandle directory pipe link symlink"
|
271
|
+
.IX Item "Functions for filehandles, files, or directories"
|
272
|
+
\&\f(CW\*(C`\-\f(CIX\f(CW\*(C'\fR, \f(CW\*(C`chdir\*(C'\fR, \f(CW\*(C`chmod\*(C'\fR, \f(CW\*(C`chown\*(C'\fR, \f(CW\*(C`chroot\*(C'\fR, \f(CW\*(C`fcntl\*(C'\fR, \f(CW\*(C`glob\*(C'\fR,
|
273
|
+
\&\f(CW\*(C`ioctl\*(C'\fR, \f(CW\*(C`link\*(C'\fR, \f(CW\*(C`lstat\*(C'\fR, \f(CW\*(C`mkdir\*(C'\fR, \f(CW\*(C`open\*(C'\fR, \f(CW\*(C`opendir\*(C'\fR,
|
274
|
+
\&\f(CW\*(C`readlink\*(C'\fR, \f(CW\*(C`rename\*(C'\fR, \f(CW\*(C`rmdir\*(C'\fR, \f(CW\*(C`stat\*(C'\fR, \f(CW\*(C`symlink\*(C'\fR, \f(CW\*(C`sysopen\*(C'\fR,
|
275
|
+
\&\f(CW\*(C`umask\*(C'\fR, \f(CW\*(C`unlink\*(C'\fR, \f(CW\*(C`utime\*(C'\fR
|
276
|
+
.IP "Keywords related to the control flow of your Perl program" 4
|
277
|
+
.IX Xref "control flow"
|
278
|
+
.IX Item "Keywords related to the control flow of your Perl program"
|
279
|
+
\&\f(CW\*(C`caller\*(C'\fR, \f(CW\*(C`continue\*(C'\fR, \f(CW\*(C`die\*(C'\fR, \f(CW\*(C`do\*(C'\fR, \f(CW\*(C`dump\*(C'\fR, \f(CW\*(C`eval\*(C'\fR, \f(CW\*(C`exit\*(C'\fR,
|
280
|
+
\&\f(CW\*(C`goto\*(C'\fR, \f(CW\*(C`last\*(C'\fR, \f(CW\*(C`next\*(C'\fR, \f(CW\*(C`redo\*(C'\fR, \f(CW\*(C`return\*(C'\fR, \f(CW\*(C`sub\*(C'\fR, \f(CW\*(C`wantarray\*(C'\fR
|
281
|
+
.IP "Keywords related to scoping" 4
|
282
|
+
.IX Item "Keywords related to scoping"
|
283
|
+
\&\f(CW\*(C`caller\*(C'\fR, \f(CW\*(C`import\*(C'\fR, \f(CW\*(C`local\*(C'\fR, \f(CW\*(C`my\*(C'\fR, \f(CW\*(C`our\*(C'\fR, \f(CW\*(C`package\*(C'\fR, \f(CW\*(C`use\*(C'\fR
|
284
|
+
.IP "Miscellaneous functions" 4
|
285
|
+
.IX Item "Miscellaneous functions"
|
286
|
+
\&\f(CW\*(C`defined\*(C'\fR, \f(CW\*(C`dump\*(C'\fR, \f(CW\*(C`eval\*(C'\fR, \f(CW\*(C`formline\*(C'\fR, \f(CW\*(C`local\*(C'\fR, \f(CW\*(C`my\*(C'\fR, \f(CW\*(C`our\*(C'\fR, \f(CW\*(C`reset\*(C'\fR,
|
287
|
+
\&\f(CW\*(C`scalar\*(C'\fR, \f(CW\*(C`undef\*(C'\fR, \f(CW\*(C`wantarray\*(C'\fR
|
288
|
+
.IP "Functions for processes and process groups" 4
|
289
|
+
.IX Xref "process pid process id"
|
290
|
+
.IX Item "Functions for processes and process groups"
|
291
|
+
\&\f(CW\*(C`alarm\*(C'\fR, \f(CW\*(C`exec\*(C'\fR, \f(CW\*(C`fork\*(C'\fR, \f(CW\*(C`getpgrp\*(C'\fR, \f(CW\*(C`getppid\*(C'\fR, \f(CW\*(C`getpriority\*(C'\fR, \f(CW\*(C`kill\*(C'\fR,
|
292
|
+
\&\f(CW\*(C`pipe\*(C'\fR, \f(CW\*(C`qx/STRING/\*(C'\fR, \f(CW\*(C`setpgrp\*(C'\fR, \f(CW\*(C`setpriority\*(C'\fR, \f(CW\*(C`sleep\*(C'\fR, \f(CW\*(C`system\*(C'\fR,
|
293
|
+
\&\f(CW\*(C`times\*(C'\fR, \f(CW\*(C`wait\*(C'\fR, \f(CW\*(C`waitpid\*(C'\fR
|
294
|
+
.IP "Keywords related to perl modules" 4
|
295
|
+
.IX Xref "module"
|
296
|
+
.IX Item "Keywords related to perl modules"
|
297
|
+
\&\f(CW\*(C`do\*(C'\fR, \f(CW\*(C`import\*(C'\fR, \f(CW\*(C`no\*(C'\fR, \f(CW\*(C`package\*(C'\fR, \f(CW\*(C`require\*(C'\fR, \f(CW\*(C`use\*(C'\fR
|
298
|
+
.IP "Keywords related to classes and object-orientedness" 4
|
299
|
+
.IX Xref "object class package"
|
300
|
+
.IX Item "Keywords related to classes and object-orientedness"
|
301
|
+
\&\f(CW\*(C`bless\*(C'\fR, \f(CW\*(C`dbmclose\*(C'\fR, \f(CW\*(C`dbmopen\*(C'\fR, \f(CW\*(C`package\*(C'\fR, \f(CW\*(C`ref\*(C'\fR, \f(CW\*(C`tie\*(C'\fR, \f(CW\*(C`tied\*(C'\fR,
|
302
|
+
\&\f(CW\*(C`untie\*(C'\fR, \f(CW\*(C`use\*(C'\fR
|
303
|
+
.IP "Low-level socket functions" 4
|
304
|
+
.IX Xref "socket sock"
|
305
|
+
.IX Item "Low-level socket functions"
|
306
|
+
\&\f(CW\*(C`accept\*(C'\fR, \f(CW\*(C`bind\*(C'\fR, \f(CW\*(C`connect\*(C'\fR, \f(CW\*(C`getpeername\*(C'\fR, \f(CW\*(C`getsockname\*(C'\fR,
|
307
|
+
\&\f(CW\*(C`getsockopt\*(C'\fR, \f(CW\*(C`listen\*(C'\fR, \f(CW\*(C`recv\*(C'\fR, \f(CW\*(C`send\*(C'\fR, \f(CW\*(C`setsockopt\*(C'\fR, \f(CW\*(C`shutdown\*(C'\fR,
|
308
|
+
\&\f(CW\*(C`socket\*(C'\fR, \f(CW\*(C`socketpair\*(C'\fR
|
309
|
+
.IP "System V interprocess communication functions" 4
|
310
|
+
.IX Xref "IPC System V semaphore shared memory memory message"
|
311
|
+
.IX Item "System V interprocess communication functions"
|
312
|
+
\&\f(CW\*(C`msgctl\*(C'\fR, \f(CW\*(C`msgget\*(C'\fR, \f(CW\*(C`msgrcv\*(C'\fR, \f(CW\*(C`msgsnd\*(C'\fR, \f(CW\*(C`semctl\*(C'\fR, \f(CW\*(C`semget\*(C'\fR, \f(CW\*(C`semop\*(C'\fR,
|
313
|
+
\&\f(CW\*(C`shmctl\*(C'\fR, \f(CW\*(C`shmget\*(C'\fR, \f(CW\*(C`shmread\*(C'\fR, \f(CW\*(C`shmwrite\*(C'\fR
|
314
|
+
.IP "Fetching user and group info" 4
|
315
|
+
.IX Xref "user group password uid gid passwd etc passwd"
|
316
|
+
.IX Item "Fetching user and group info"
|
317
|
+
\&\f(CW\*(C`endgrent\*(C'\fR, \f(CW\*(C`endhostent\*(C'\fR, \f(CW\*(C`endnetent\*(C'\fR, \f(CW\*(C`endpwent\*(C'\fR, \f(CW\*(C`getgrent\*(C'\fR,
|
318
|
+
\&\f(CW\*(C`getgrgid\*(C'\fR, \f(CW\*(C`getgrnam\*(C'\fR, \f(CW\*(C`getlogin\*(C'\fR, \f(CW\*(C`getpwent\*(C'\fR, \f(CW\*(C`getpwnam\*(C'\fR,
|
319
|
+
\&\f(CW\*(C`getpwuid\*(C'\fR, \f(CW\*(C`setgrent\*(C'\fR, \f(CW\*(C`setpwent\*(C'\fR
|
320
|
+
.IP "Fetching network info" 4
|
321
|
+
.IX Xref "network protocol host hostname IP address service"
|
322
|
+
.IX Item "Fetching network info"
|
323
|
+
\&\f(CW\*(C`endprotoent\*(C'\fR, \f(CW\*(C`endservent\*(C'\fR, \f(CW\*(C`gethostbyaddr\*(C'\fR, \f(CW\*(C`gethostbyname\*(C'\fR,
|
324
|
+
\&\f(CW\*(C`gethostent\*(C'\fR, \f(CW\*(C`getnetbyaddr\*(C'\fR, \f(CW\*(C`getnetbyname\*(C'\fR, \f(CW\*(C`getnetent\*(C'\fR,
|
325
|
+
\&\f(CW\*(C`getprotobyname\*(C'\fR, \f(CW\*(C`getprotobynumber\*(C'\fR, \f(CW\*(C`getprotoent\*(C'\fR,
|
326
|
+
\&\f(CW\*(C`getservbyname\*(C'\fR, \f(CW\*(C`getservbyport\*(C'\fR, \f(CW\*(C`getservent\*(C'\fR, \f(CW\*(C`sethostent\*(C'\fR,
|
327
|
+
\&\f(CW\*(C`setnetent\*(C'\fR, \f(CW\*(C`setprotoent\*(C'\fR, \f(CW\*(C`setservent\*(C'\fR
|
328
|
+
.IP "Time-related functions" 4
|
329
|
+
.IX Xref "time date"
|
330
|
+
.IX Item "Time-related functions"
|
331
|
+
\&\f(CW\*(C`gmtime\*(C'\fR, \f(CW\*(C`localtime\*(C'\fR, \f(CW\*(C`time\*(C'\fR, \f(CW\*(C`times\*(C'\fR
|
332
|
+
.IP "Functions new in perl5" 4
|
333
|
+
.IX Xref "perl5"
|
334
|
+
.IX Item "Functions new in perl5"
|
335
|
+
\&\f(CW\*(C`abs\*(C'\fR, \f(CW\*(C`bless\*(C'\fR, \f(CW\*(C`chomp\*(C'\fR, \f(CW\*(C`chr\*(C'\fR, \f(CW\*(C`exists\*(C'\fR, \f(CW\*(C`formline\*(C'\fR, \f(CW\*(C`glob\*(C'\fR,
|
336
|
+
\&\f(CW\*(C`import\*(C'\fR, \f(CW\*(C`lc\*(C'\fR, \f(CW\*(C`lcfirst\*(C'\fR, \f(CW\*(C`map\*(C'\fR, \f(CW\*(C`my\*(C'\fR, \f(CW\*(C`no\*(C'\fR, \f(CW\*(C`our\*(C'\fR, \f(CW\*(C`prototype\*(C'\fR,
|
337
|
+
\&\f(CW\*(C`qx\*(C'\fR, \f(CW\*(C`qw\*(C'\fR, \f(CW\*(C`readline\*(C'\fR, \f(CW\*(C`readpipe\*(C'\fR, \f(CW\*(C`ref\*(C'\fR, \f(CW\*(C`sub*\*(C'\fR, \f(CW\*(C`sysopen\*(C'\fR, \f(CW\*(C`tie\*(C'\fR,
|
338
|
+
\&\f(CW\*(C`tied\*(C'\fR, \f(CW\*(C`uc\*(C'\fR, \f(CW\*(C`ucfirst\*(C'\fR, \f(CW\*(C`untie\*(C'\fR, \f(CW\*(C`use\*(C'\fR
|
339
|
+
.Sp
|
340
|
+
* \- \f(CW\*(C`sub\*(C'\fR was a keyword in perl4, but in perl5 it is an
|
341
|
+
operator, which can be used in expressions.
|
342
|
+
.IP "Functions obsoleted in perl5" 4
|
343
|
+
.IX Item "Functions obsoleted in perl5"
|
344
|
+
\&\f(CW\*(C`dbmclose\*(C'\fR, \f(CW\*(C`dbmopen\*(C'\fR
|
345
|
+
.Sh "Portability"
|
346
|
+
.IX Xref "portability Unix portable"
|
347
|
+
.IX Subsection "Portability"
|
348
|
+
Perl was born in Unix and can therefore access all common Unix
|
349
|
+
system calls. In non-Unix environments, the functionality of some
|
350
|
+
Unix system calls may not be available, or details of the available
|
351
|
+
functionality may differ slightly. The Perl functions affected
|
352
|
+
by this are:
|
353
|
+
.PP
|
354
|
+
\&\f(CW\*(C`\-X\*(C'\fR, \f(CW\*(C`binmode\*(C'\fR, \f(CW\*(C`chmod\*(C'\fR, \f(CW\*(C`chown\*(C'\fR, \f(CW\*(C`chroot\*(C'\fR, \f(CW\*(C`crypt\*(C'\fR,
|
355
|
+
\&\f(CW\*(C`dbmclose\*(C'\fR, \f(CW\*(C`dbmopen\*(C'\fR, \f(CW\*(C`dump\*(C'\fR, \f(CW\*(C`endgrent\*(C'\fR, \f(CW\*(C`endhostent\*(C'\fR,
|
356
|
+
\&\f(CW\*(C`endnetent\*(C'\fR, \f(CW\*(C`endprotoent\*(C'\fR, \f(CW\*(C`endpwent\*(C'\fR, \f(CW\*(C`endservent\*(C'\fR, \f(CW\*(C`exec\*(C'\fR,
|
357
|
+
\&\f(CW\*(C`fcntl\*(C'\fR, \f(CW\*(C`flock\*(C'\fR, \f(CW\*(C`fork\*(C'\fR, \f(CW\*(C`getgrent\*(C'\fR, \f(CW\*(C`getgrgid\*(C'\fR, \f(CW\*(C`gethostbyname\*(C'\fR,
|
358
|
+
\&\f(CW\*(C`gethostent\*(C'\fR, \f(CW\*(C`getlogin\*(C'\fR, \f(CW\*(C`getnetbyaddr\*(C'\fR, \f(CW\*(C`getnetbyname\*(C'\fR, \f(CW\*(C`getnetent\*(C'\fR,
|
359
|
+
\&\f(CW\*(C`getppid\*(C'\fR, \f(CW\*(C`getpgrp\*(C'\fR, \f(CW\*(C`getpriority\*(C'\fR, \f(CW\*(C`getprotobynumber\*(C'\fR,
|
360
|
+
\&\f(CW\*(C`getprotoent\*(C'\fR, \f(CW\*(C`getpwent\*(C'\fR, \f(CW\*(C`getpwnam\*(C'\fR, \f(CW\*(C`getpwuid\*(C'\fR,
|
361
|
+
\&\f(CW\*(C`getservbyport\*(C'\fR, \f(CW\*(C`getservent\*(C'\fR, \f(CW\*(C`getsockopt\*(C'\fR, \f(CW\*(C`glob\*(C'\fR, \f(CW\*(C`ioctl\*(C'\fR,
|
362
|
+
\&\f(CW\*(C`kill\*(C'\fR, \f(CW\*(C`link\*(C'\fR, \f(CW\*(C`lstat\*(C'\fR, \f(CW\*(C`msgctl\*(C'\fR, \f(CW\*(C`msgget\*(C'\fR, \f(CW\*(C`msgrcv\*(C'\fR,
|
363
|
+
\&\f(CW\*(C`msgsnd\*(C'\fR, \f(CW\*(C`open\*(C'\fR, \f(CW\*(C`pipe\*(C'\fR, \f(CW\*(C`readlink\*(C'\fR, \f(CW\*(C`rename\*(C'\fR, \f(CW\*(C`select\*(C'\fR, \f(CW\*(C`semctl\*(C'\fR,
|
364
|
+
\&\f(CW\*(C`semget\*(C'\fR, \f(CW\*(C`semop\*(C'\fR, \f(CW\*(C`setgrent\*(C'\fR, \f(CW\*(C`sethostent\*(C'\fR, \f(CW\*(C`setnetent\*(C'\fR,
|
365
|
+
\&\f(CW\*(C`setpgrp\*(C'\fR, \f(CW\*(C`setpriority\*(C'\fR, \f(CW\*(C`setprotoent\*(C'\fR, \f(CW\*(C`setpwent\*(C'\fR,
|
366
|
+
\&\f(CW\*(C`setservent\*(C'\fR, \f(CW\*(C`setsockopt\*(C'\fR, \f(CW\*(C`shmctl\*(C'\fR, \f(CW\*(C`shmget\*(C'\fR, \f(CW\*(C`shmread\*(C'\fR,
|
367
|
+
\&\f(CW\*(C`shmwrite\*(C'\fR, \f(CW\*(C`socket\*(C'\fR, \f(CW\*(C`socketpair\*(C'\fR,
|
368
|
+
\&\f(CW\*(C`stat\*(C'\fR, \f(CW\*(C`symlink\*(C'\fR, \f(CW\*(C`syscall\*(C'\fR, \f(CW\*(C`sysopen\*(C'\fR, \f(CW\*(C`system\*(C'\fR,
|
369
|
+
\&\f(CW\*(C`times\*(C'\fR, \f(CW\*(C`truncate\*(C'\fR, \f(CW\*(C`umask\*(C'\fR, \f(CW\*(C`unlink\*(C'\fR,
|
370
|
+
\&\f(CW\*(C`utime\*(C'\fR, \f(CW\*(C`wait\*(C'\fR, \f(CW\*(C`waitpid\*(C'\fR
|
371
|
+
.PP
|
372
|
+
For more information about the portability of these functions, see
|
373
|
+
perlport and other available platform-specific documentation.
|
374
|
+
.Sh "Alphabetical Listing of Perl Functions"
|
375
|
+
.IX Subsection "Alphabetical Listing of Perl Functions"
|
376
|
+
.IP "\-X \s-1FILEHANDLE\s0" 8
|
377
|
+
.IX Xref "-r -w -x -o -R -W -X -O -e -z -s -f -d -l -p -S -b -c -t -u -g -k -T -B -M -A -C"
|
378
|
+
.IX Item "-X FILEHANDLE"
|
379
|
+
.PD 0
|
380
|
+
.IP "\-X \s-1EXPR\s0" 8
|
381
|
+
.IX Item "-X EXPR"
|
382
|
+
.IP "\-X" 8
|
383
|
+
.IX Item "-X"
|
384
|
+
.PD
|
385
|
+
A file test, where X is one of the letters listed below. This unary
|
386
|
+
operator takes one argument, either a filename or a filehandle, and
|
387
|
+
tests the associated file to see if something is true about it. If the
|
388
|
+
argument is omitted, tests \f(CW$_\fR, except for \f(CW\*(C`\-t\*(C'\fR, which tests \s-1STDIN\s0.
|
389
|
+
Unless otherwise documented, it returns \f(CW1\fR for true and \f(CW''\fR for false, or
|
390
|
+
the undefined value if the file doesn't exist. Despite the funny
|
391
|
+
names, precedence is the same as any other named unary operator, and
|
392
|
+
the argument may be parenthesized like any other unary operator. The
|
393
|
+
operator may be any of:
|
394
|
+
.Sp
|
395
|
+
.Vb 4
|
396
|
+
\& -r File is readable by effective uid/gid.
|
397
|
+
\& -w File is writable by effective uid/gid.
|
398
|
+
\& -x File is executable by effective uid/gid.
|
399
|
+
\& -o File is owned by effective uid.
|
400
|
+
.Ve
|
401
|
+
.Sp
|
402
|
+
.Vb 4
|
403
|
+
\& -R File is readable by real uid/gid.
|
404
|
+
\& -W File is writable by real uid/gid.
|
405
|
+
\& -X File is executable by real uid/gid.
|
406
|
+
\& -O File is owned by real uid.
|
407
|
+
.Ve
|
408
|
+
.Sp
|
409
|
+
.Vb 3
|
410
|
+
\& -e File exists.
|
411
|
+
\& -z File has zero size (is empty).
|
412
|
+
\& -s File has nonzero size (returns size in bytes).
|
413
|
+
.Ve
|
414
|
+
.Sp
|
415
|
+
.Vb 8
|
416
|
+
\& -f File is a plain file.
|
417
|
+
\& -d File is a directory.
|
418
|
+
\& -l File is a symbolic link.
|
419
|
+
\& -p File is a named pipe (FIFO), or Filehandle is a pipe.
|
420
|
+
\& -S File is a socket.
|
421
|
+
\& -b File is a block special file.
|
422
|
+
\& -c File is a character special file.
|
423
|
+
\& -t Filehandle is opened to a tty.
|
424
|
+
.Ve
|
425
|
+
.Sp
|
426
|
+
.Vb 3
|
427
|
+
\& -u File has setuid bit set.
|
428
|
+
\& -g File has setgid bit set.
|
429
|
+
\& -k File has sticky bit set.
|
430
|
+
.Ve
|
431
|
+
.Sp
|
432
|
+
.Vb 2
|
433
|
+
\& -T File is an ASCII text file (heuristic guess).
|
434
|
+
\& -B File is a "binary" file (opposite of -T).
|
435
|
+
.Ve
|
436
|
+
.Sp
|
437
|
+
.Vb 3
|
438
|
+
\& -M Script start time minus file modification time, in days.
|
439
|
+
\& -A Same for access time.
|
440
|
+
\& -C Same for inode change time (Unix, may differ for other platforms)
|
441
|
+
.Ve
|
442
|
+
.Sp
|
443
|
+
Example:
|
444
|
+
.Sp
|
445
|
+
.Vb 5
|
446
|
+
\& while (<>) {
|
447
|
+
\& chomp;
|
448
|
+
\& next unless -f $_; # ignore specials
|
449
|
+
\& #...
|
450
|
+
\& }
|
451
|
+
.Ve
|
452
|
+
.Sp
|
453
|
+
The interpretation of the file permission operators \f(CW\*(C`\-r\*(C'\fR, \f(CW\*(C`\-R\*(C'\fR,
|
454
|
+
\&\f(CW\*(C`\-w\*(C'\fR, \f(CW\*(C`\-W\*(C'\fR, \f(CW\*(C`\-x\*(C'\fR, and \f(CW\*(C`\-X\*(C'\fR is by default based solely on the mode
|
455
|
+
of the file and the uids and gids of the user. There may be other
|
456
|
+
reasons you can't actually read, write, or execute the file. Such
|
457
|
+
reasons may be for example network filesystem access controls, ACLs
|
458
|
+
(access control lists), read-only filesystems, and unrecognized
|
459
|
+
executable formats.
|
460
|
+
.Sp
|
461
|
+
Also note that, for the superuser on the local filesystems, the \f(CW\*(C`\-r\*(C'\fR,
|
462
|
+
\&\f(CW\*(C`\-R\*(C'\fR, \f(CW\*(C`\-w\*(C'\fR, and \f(CW\*(C`\-W\*(C'\fR tests always return 1, and \f(CW\*(C`\-x\*(C'\fR and \f(CW\*(C`\-X\*(C'\fR return 1
|
463
|
+
if any execute bit is set in the mode. Scripts run by the superuser
|
464
|
+
may thus need to do a \fIstat()\fR to determine the actual mode of the file,
|
465
|
+
or temporarily set their effective uid to something else.
|
466
|
+
.Sp
|
467
|
+
If you are using ACLs, there is a pragma called \f(CW\*(C`filetest\*(C'\fR that may
|
468
|
+
produce more accurate results than the bare \fIstat()\fR mode bits.
|
469
|
+
When under the \f(CW\*(C`use filetest 'access'\*(C'\fR the above-mentioned filetests
|
470
|
+
will test whether the permission can (not) be granted using the
|
471
|
+
\&\fIaccess()\fR family of system calls. Also note that the \f(CW\*(C`\-x\*(C'\fR and \f(CW\*(C`\-X\*(C'\fR may
|
472
|
+
under this pragma return true even if there are no execute permission
|
473
|
+
bits set (nor any extra execute permission ACLs). This strangeness is
|
474
|
+
due to the underlying system calls' definitions. Read the
|
475
|
+
documentation for the \f(CW\*(C`filetest\*(C'\fR pragma for more information.
|
476
|
+
.Sp
|
477
|
+
Note that \f(CW\*(C`\-s/a/b/\*(C'\fR does not do a negated substitution. Saying
|
478
|
+
\&\f(CW\*(C`\-exp($foo)\*(C'\fR still works as expected, however\*(--only single letters
|
479
|
+
following a minus are interpreted as file tests.
|
480
|
+
.Sp
|
481
|
+
The \f(CW\*(C`\-T\*(C'\fR and \f(CW\*(C`\-B\*(C'\fR switches work as follows. The first block or so of the
|
482
|
+
file is examined for odd characters such as strange control codes or
|
483
|
+
characters with the high bit set. If too many strange characters (>30%)
|
484
|
+
are found, it's a \f(CW\*(C`\-B\*(C'\fR file; otherwise it's a \f(CW\*(C`\-T\*(C'\fR file. Also, any file
|
485
|
+
containing null in the first block is considered a binary file. If \f(CW\*(C`\-T\*(C'\fR
|
486
|
+
or \f(CW\*(C`\-B\*(C'\fR is used on a filehandle, the current \s-1IO\s0 buffer is examined
|
487
|
+
rather than the first block. Both \f(CW\*(C`\-T\*(C'\fR and \f(CW\*(C`\-B\*(C'\fR return true on a null
|
488
|
+
file, or a file at \s-1EOF\s0 when testing a filehandle. Because you have to
|
489
|
+
read a file to do the \f(CW\*(C`\-T\*(C'\fR test, on most occasions you want to use a \f(CW\*(C`\-f\*(C'\fR
|
490
|
+
against the file first, as in \f(CW\*(C`next unless \-f $file && \-T $file\*(C'\fR.
|
491
|
+
.Sp
|
492
|
+
If any of the file tests (or either the \f(CW\*(C`stat\*(C'\fR or \f(CW\*(C`lstat\*(C'\fR operators) are given
|
493
|
+
the special filehandle consisting of a solitary underline, then the stat
|
494
|
+
structure of the previous file test (or stat operator) is used, saving
|
495
|
+
a system call. (This doesn't work with \f(CW\*(C`\-t\*(C'\fR, and you need to remember
|
496
|
+
that \fIlstat()\fR and \f(CW\*(C`\-l\*(C'\fR will leave values in the stat structure for the
|
497
|
+
symbolic link, not the real file.) (Also, if the stat buffer was filled by
|
498
|
+
an \f(CW\*(C`lstat\*(C'\fR call, \f(CW\*(C`\-T\*(C'\fR and \f(CW\*(C`\-B\*(C'\fR will reset it with the results of \f(CW\*(C`stat _\*(C'\fR).
|
499
|
+
Example:
|
500
|
+
.Sp
|
501
|
+
.Vb 1
|
502
|
+
\& print "Can do.\en" if -r $a || -w _ || -x _;
|
503
|
+
.Ve
|
504
|
+
.Sp
|
505
|
+
.Vb 9
|
506
|
+
\& stat($filename);
|
507
|
+
\& print "Readable\en" if -r _;
|
508
|
+
\& print "Writable\en" if -w _;
|
509
|
+
\& print "Executable\en" if -x _;
|
510
|
+
\& print "Setuid\en" if -u _;
|
511
|
+
\& print "Setgid\en" if -g _;
|
512
|
+
\& print "Sticky\en" if -k _;
|
513
|
+
\& print "Text\en" if -T _;
|
514
|
+
\& print "Binary\en" if -B _;
|
515
|
+
.Ve
|
516
|
+
.IP "abs \s-1VALUE\s0" 8
|
517
|
+
.IX Xref "abs absolute"
|
518
|
+
.IX Item "abs VALUE"
|
519
|
+
.PD 0
|
520
|
+
.IP "abs" 8
|
521
|
+
.IX Item "abs"
|
522
|
+
.PD
|
523
|
+
Returns the absolute value of its argument.
|
524
|
+
If \s-1VALUE\s0 is omitted, uses \f(CW$_\fR.
|
525
|
+
.IP "accept \s-1NEWSOCKET\s0,GENERICSOCKET" 8
|
526
|
+
.IX Xref "accept"
|
527
|
+
.IX Item "accept NEWSOCKET,GENERICSOCKET"
|
528
|
+
Accepts an incoming socket connect, just as the \fIaccept\fR\|(2) system call
|
529
|
+
does. Returns the packed address if it succeeded, false otherwise.
|
530
|
+
See the example in \*(L"Sockets: Client/Server Communication\*(R" in perlipc.
|
531
|
+
.Sp
|
532
|
+
On systems that support a close-on-exec flag on files, the flag will
|
533
|
+
be set for the newly opened file descriptor, as determined by the
|
534
|
+
value of $^F. See \*(L"$^F\*(R" in perlvar.
|
535
|
+
.IP "alarm \s-1SECONDS\s0" 8
|
536
|
+
.IX Xref "alarm SIGALRM timer"
|
537
|
+
.IX Item "alarm SECONDS"
|
538
|
+
.PD 0
|
539
|
+
.IP "alarm" 8
|
540
|
+
.IX Item "alarm"
|
541
|
+
.PD
|
542
|
+
Arranges to have a \s-1SIGALRM\s0 delivered to this process after the
|
543
|
+
specified number of wallclock seconds has elapsed. If \s-1SECONDS\s0 is not
|
544
|
+
specified, the value stored in \f(CW$_\fR is used. (On some machines,
|
545
|
+
unfortunately, the elapsed time may be up to one second less or more
|
546
|
+
than you specified because of how seconds are counted, and process
|
547
|
+
scheduling may delay the delivery of the signal even further.)
|
548
|
+
.Sp
|
549
|
+
Only one timer may be counting at once. Each call disables the
|
550
|
+
previous timer, and an argument of \f(CW0\fR may be supplied to cancel the
|
551
|
+
previous timer without starting a new one. The returned value is the
|
552
|
+
amount of time remaining on the previous timer.
|
553
|
+
.Sp
|
554
|
+
For delays of finer granularity than one second, you may use Perl's
|
555
|
+
four-argument version of \fIselect()\fR leaving the first three arguments
|
556
|
+
undefined, or you might be able to use the \f(CW\*(C`syscall\*(C'\fR interface to
|
557
|
+
access \fIsetitimer\fR\|(2) if your system supports it. The Time::HiRes
|
558
|
+
module (from \s-1CPAN\s0, and starting from Perl 5.8 part of the standard
|
559
|
+
distribution) may also prove useful.
|
560
|
+
.Sp
|
561
|
+
It is usually a mistake to intermix \f(CW\*(C`alarm\*(C'\fR and \f(CW\*(C`sleep\*(C'\fR calls.
|
562
|
+
(\f(CW\*(C`sleep\*(C'\fR may be internally implemented in your system with \f(CW\*(C`alarm\*(C'\fR)
|
563
|
+
.Sp
|
564
|
+
If you want to use \f(CW\*(C`alarm\*(C'\fR to time out a system call you need to use an
|
565
|
+
\&\f(CW\*(C`eval\*(C'\fR/\f(CW\*(C`die\*(C'\fR pair. You can't rely on the alarm causing the system call to
|
566
|
+
fail with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR because Perl sets up signal handlers to
|
567
|
+
restart system calls on some systems. Using \f(CW\*(C`eval\*(C'\fR/\f(CW\*(C`die\*(C'\fR always works,
|
568
|
+
modulo the caveats given in \*(L"Signals\*(R" in perlipc.
|
569
|
+
.Sp
|
570
|
+
.Vb 13
|
571
|
+
\& eval {
|
572
|
+
\& local $SIG{ALRM} = sub { die "alarm\en" }; # NB: \en required
|
573
|
+
\& alarm $timeout;
|
574
|
+
\& $nread = sysread SOCKET, $buffer, $size;
|
575
|
+
\& alarm 0;
|
576
|
+
\& };
|
577
|
+
\& if ($@) {
|
578
|
+
\& die unless $@ eq "alarm\en"; # propagate unexpected errors
|
579
|
+
\& # timed out
|
580
|
+
\& }
|
581
|
+
\& else {
|
582
|
+
\& # didn't
|
583
|
+
\& }
|
584
|
+
.Ve
|
585
|
+
.Sp
|
586
|
+
For more information see perlipc.
|
587
|
+
.IP "atan2 Y,X" 8
|
588
|
+
.IX Xref "atan2 arctangent tan tangent"
|
589
|
+
.IX Item "atan2 Y,X"
|
590
|
+
Returns the arctangent of Y/X in the range \-PI to \s-1PI\s0.
|
591
|
+
.Sp
|
592
|
+
For the tangent operation, you may use the \f(CW\*(C`Math::Trig::tan\*(C'\fR
|
593
|
+
function, or use the familiar relation:
|
594
|
+
.Sp
|
595
|
+
.Vb 1
|
596
|
+
\& sub tan { sin($_[0]) / cos($_[0]) }
|
597
|
+
.Ve
|
598
|
+
.Sp
|
599
|
+
Note that atan2(0, 0) is not well\-defined.
|
600
|
+
.IP "bind \s-1SOCKET\s0,NAME" 8
|
601
|
+
.IX Xref "bind"
|
602
|
+
.IX Item "bind SOCKET,NAME"
|
603
|
+
Binds a network address to a socket, just as the bind system call
|
604
|
+
does. Returns true if it succeeded, false otherwise. \s-1NAME\s0 should be a
|
605
|
+
packed address of the appropriate type for the socket. See the examples in
|
606
|
+
\&\*(L"Sockets: Client/Server Communication\*(R" in perlipc.
|
607
|
+
.IP "binmode \s-1FILEHANDLE\s0, \s-1LAYER\s0" 8
|
608
|
+
.IX Xref "binmode binary text DOS Windows"
|
609
|
+
.IX Item "binmode FILEHANDLE, LAYER"
|
610
|
+
.PD 0
|
611
|
+
.IP "binmode \s-1FILEHANDLE\s0" 8
|
612
|
+
.IX Item "binmode FILEHANDLE"
|
613
|
+
.PD
|
614
|
+
Arranges for \s-1FILEHANDLE\s0 to be read or written in \*(L"binary\*(R" or \*(L"text\*(R"
|
615
|
+
mode on systems where the run-time libraries distinguish between
|
616
|
+
binary and text files. If \s-1FILEHANDLE\s0 is an expression, the value is
|
617
|
+
taken as the name of the filehandle. Returns true on success,
|
618
|
+
otherwise it returns \f(CW\*(C`undef\*(C'\fR and sets \f(CW$!\fR (errno).
|
619
|
+
.Sp
|
620
|
+
On some systems (in general, \s-1DOS\s0 and Windows-based systems) \fIbinmode()\fR
|
621
|
+
is necessary when you're not working with a text file. For the sake
|
622
|
+
of portability it is a good idea to always use it when appropriate,
|
623
|
+
and to never use it when it isn't appropriate. Also, people can
|
624
|
+
set their I/O to be by default \s-1UTF\-8\s0 encoded Unicode, not bytes.
|
625
|
+
.Sp
|
626
|
+
In other words: regardless of platform, use \fIbinmode()\fR on binary data,
|
627
|
+
like for example images.
|
628
|
+
.Sp
|
629
|
+
If \s-1LAYER\s0 is present it is a single string, but may contain multiple
|
630
|
+
directives. The directives alter the behaviour of the file handle.
|
631
|
+
When \s-1LAYER\s0 is present using binmode on text file makes sense.
|
632
|
+
.Sp
|
633
|
+
If \s-1LAYER\s0 is omitted or specified as \f(CW\*(C`:raw\*(C'\fR the filehandle is made
|
634
|
+
suitable for passing binary data. This includes turning off possible \s-1CRLF\s0
|
635
|
+
translation and marking it as bytes (as opposed to Unicode characters).
|
636
|
+
Note that, despite what may be implied in \fI\*(L"Programming Perl\*(R"\fR (the
|
637
|
+
Camel) or elsewhere, \f(CW\*(C`:raw\*(C'\fR is \fInot\fR the simply inverse of \f(CW\*(C`:crlf\*(C'\fR
|
638
|
+
\&\*(-- other layers which would affect binary nature of the stream are
|
639
|
+
\&\fIalso\fR disabled. See PerlIO, perlrun and the discussion about the
|
640
|
+
\&\s-1PERLIO\s0 environment variable.
|
641
|
+
.Sp
|
642
|
+
The \f(CW\*(C`:bytes\*(C'\fR, \f(CW\*(C`:crlf\*(C'\fR, and \f(CW\*(C`:utf8\*(C'\fR, and any other directives of the
|
643
|
+
form \f(CW\*(C`:...\*(C'\fR, are called I/O \fIlayers\fR. The \f(CW\*(C`open\*(C'\fR pragma can be used to
|
644
|
+
establish default I/O layers. See open.
|
645
|
+
.Sp
|
646
|
+
\&\fIThe \s-1LAYER\s0 parameter of the \fIbinmode()\fI function is described as \*(L"\s-1DISCIPLINE\s0\*(R"
|
647
|
+
in \*(L"Programming Perl, 3rd Edition\*(R". However, since the publishing of this
|
648
|
+
book, by many known as \*(L"Camel \s-1III\s0\*(R", the consensus of the naming of this
|
649
|
+
functionality has moved from \*(L"discipline\*(R" to \*(L"layer\*(R". All documentation
|
650
|
+
of this version of Perl therefore refers to \*(L"layers\*(R" rather than to
|
651
|
+
\&\*(L"disciplines\*(R". Now back to the regularly scheduled documentation...\fR
|
652
|
+
.Sp
|
653
|
+
To mark \s-1FILEHANDLE\s0 as \s-1UTF\-8\s0, use \f(CW\*(C`:utf8\*(C'\fR.
|
654
|
+
.Sp
|
655
|
+
In general, \fIbinmode()\fR should be called after \fIopen()\fR but before any I/O
|
656
|
+
is done on the filehandle. Calling \fIbinmode()\fR will normally flush any
|
657
|
+
pending buffered output data (and perhaps pending input data) on the
|
658
|
+
handle. An exception to this is the \f(CW\*(C`:encoding\*(C'\fR layer that
|
659
|
+
changes the default character encoding of the handle, see open.
|
660
|
+
The \f(CW\*(C`:encoding\*(C'\fR layer sometimes needs to be called in
|
661
|
+
mid\-stream, and it doesn't flush the stream. The \f(CW\*(C`:encoding\*(C'\fR
|
662
|
+
also implicitly pushes on top of itself the \f(CW\*(C`:utf8\*(C'\fR layer because
|
663
|
+
internally Perl will operate on \s-1UTF\-8\s0 encoded Unicode characters.
|
664
|
+
.Sp
|
665
|
+
The operating system, device drivers, C libraries, and Perl run-time
|
666
|
+
system all work together to let the programmer treat a single
|
667
|
+
character (\f(CW\*(C`\en\*(C'\fR) as the line terminator, irrespective of the external
|
668
|
+
representation. On many operating systems, the native text file
|
669
|
+
representation matches the internal representation, but on some
|
670
|
+
platforms the external representation of \f(CW\*(C`\en\*(C'\fR is made up of more than
|
671
|
+
one character.
|
672
|
+
.Sp
|
673
|
+
Mac \s-1OS\s0, all variants of Unix, and Stream_LF files on \s-1VMS\s0 use a single
|
674
|
+
character to end each line in the external representation of text (even
|
675
|
+
though that single character is \s-1CARRIAGE\s0 \s-1RETURN\s0 on Mac \s-1OS\s0 and \s-1LINE\s0 \s-1FEED\s0
|
676
|
+
on Unix and most \s-1VMS\s0 files). In other systems like \s-1OS/2\s0, \s-1DOS\s0 and the
|
677
|
+
various flavors of MS-Windows your program sees a \f(CW\*(C`\en\*(C'\fR as a simple \f(CW\*(C`\ecJ\*(C'\fR,
|
678
|
+
but what's stored in text files are the two characters \f(CW\*(C`\ecM\ecJ\*(C'\fR. That
|
679
|
+
means that, if you don't use \fIbinmode()\fR on these systems, \f(CW\*(C`\ecM\ecJ\*(C'\fR
|
680
|
+
sequences on disk will be converted to \f(CW\*(C`\en\*(C'\fR on input, and any \f(CW\*(C`\en\*(C'\fR in
|
681
|
+
your program will be converted back to \f(CW\*(C`\ecM\ecJ\*(C'\fR on output. This is what
|
682
|
+
you want for text files, but it can be disastrous for binary files.
|
683
|
+
.Sp
|
684
|
+
Another consequence of using \fIbinmode()\fR (on some systems) is that
|
685
|
+
special end-of-file markers will be seen as part of the data stream.
|
686
|
+
For systems from the Microsoft family this means that if your binary
|
687
|
+
data contains \f(CW\*(C`\ecZ\*(C'\fR, the I/O subsystem will regard it as the end of
|
688
|
+
the file, unless you use \fIbinmode()\fR.
|
689
|
+
.Sp
|
690
|
+
\&\fIbinmode()\fR is not only important for \fIreadline()\fR and \fIprint()\fR operations,
|
691
|
+
but also when using \fIread()\fR, \fIseek()\fR, \fIsysread()\fR, \fIsyswrite()\fR and \fItell()\fR
|
692
|
+
(see perlport for more details). See the \f(CW$/\fR and \f(CW\*(C`$\e\*(C'\fR variables
|
693
|
+
in perlvar for how to manually set your input and output
|
694
|
+
line-termination sequences.
|
695
|
+
.IP "bless \s-1REF\s0,CLASSNAME" 8
|
696
|
+
.IX Xref "bless"
|
697
|
+
.IX Item "bless REF,CLASSNAME"
|
698
|
+
.PD 0
|
699
|
+
.IP "bless \s-1REF\s0" 8
|
700
|
+
.IX Item "bless REF"
|
701
|
+
.PD
|
702
|
+
This function tells the thingy referenced by \s-1REF\s0 that it is now an object
|
703
|
+
in the \s-1CLASSNAME\s0 package. If \s-1CLASSNAME\s0 is omitted, the current package
|
704
|
+
is used. Because a \f(CW\*(C`bless\*(C'\fR is often the last thing in a constructor,
|
705
|
+
it returns the reference for convenience. Always use the two-argument
|
706
|
+
version if a derived class might inherit the function doing the blessing.
|
707
|
+
See perltoot and perlobj for more about the blessing (and blessings)
|
708
|
+
of objects.
|
709
|
+
.Sp
|
710
|
+
Consider always blessing objects in CLASSNAMEs that are mixed case.
|
711
|
+
Namespaces with all lowercase names are considered reserved for
|
712
|
+
Perl pragmata. Builtin types have all uppercase names. To prevent
|
713
|
+
confusion, you may wish to avoid such package names as well. Make sure
|
714
|
+
that \s-1CLASSNAME\s0 is a true value.
|
715
|
+
.Sp
|
716
|
+
See \*(L"Perl Modules\*(R" in perlmod.
|
717
|
+
.IP "caller \s-1EXPR\s0" 8
|
718
|
+
.IX Xref "caller call stack stack stack trace"
|
719
|
+
.IX Item "caller EXPR"
|
720
|
+
.PD 0
|
721
|
+
.IP "caller" 8
|
722
|
+
.IX Item "caller"
|
723
|
+
.PD
|
724
|
+
Returns the context of the current subroutine call. In scalar context,
|
725
|
+
returns the caller's package name if there is a caller, that is, if
|
726
|
+
we're in a subroutine or \f(CW\*(C`eval\*(C'\fR or \f(CW\*(C`require\*(C'\fR, and the undefined value
|
727
|
+
otherwise. In list context, returns
|
728
|
+
.Sp
|
729
|
+
.Vb 1
|
730
|
+
\& ($package, $filename, $line) = caller;
|
731
|
+
.Ve
|
732
|
+
.Sp
|
733
|
+
With \s-1EXPR\s0, it returns some extra information that the debugger uses to
|
734
|
+
print a stack trace. The value of \s-1EXPR\s0 indicates how many call frames
|
735
|
+
to go back before the current one.
|
736
|
+
.Sp
|
737
|
+
.Vb 2
|
738
|
+
\& ($package, $filename, $line, $subroutine, $hasargs,
|
739
|
+
\& $wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($i);
|
740
|
+
.Ve
|
741
|
+
.Sp
|
742
|
+
Here \f(CW$subroutine\fR may be \f(CW\*(C`(eval)\*(C'\fR if the frame is not a subroutine
|
743
|
+
call, but an \f(CW\*(C`eval\*(C'\fR. In such a case additional elements \f(CW$evaltext\fR and
|
744
|
+
\&\f(CW$is_require\fR are set: \f(CW$is_require\fR is true if the frame is created by a
|
745
|
+
\&\f(CW\*(C`require\*(C'\fR or \f(CW\*(C`use\*(C'\fR statement, \f(CW$evaltext\fR contains the text of the
|
746
|
+
\&\f(CW\*(C`eval EXPR\*(C'\fR statement. In particular, for an \f(CW\*(C`eval BLOCK\*(C'\fR statement,
|
747
|
+
\&\f(CW$filename\fR is \f(CW\*(C`(eval)\*(C'\fR, but \f(CW$evaltext\fR is undefined. (Note also that
|
748
|
+
each \f(CW\*(C`use\*(C'\fR statement creates a \f(CW\*(C`require\*(C'\fR frame inside an \f(CW\*(C`eval EXPR\*(C'\fR
|
749
|
+
frame.) \f(CW$subroutine\fR may also be \f(CW\*(C`(unknown)\*(C'\fR if this particular
|
750
|
+
subroutine happens to have been deleted from the symbol table.
|
751
|
+
\&\f(CW$hasargs\fR is true if a new instance of \f(CW@_\fR was set up for the frame.
|
752
|
+
\&\f(CW$hints\fR and \f(CW$bitmask\fR contain pragmatic hints that the caller was
|
753
|
+
compiled with. The \f(CW$hints\fR and \f(CW$bitmask\fR values are subject to change
|
754
|
+
between versions of Perl, and are not meant for external use.
|
755
|
+
.Sp
|
756
|
+
Furthermore, when called from within the \s-1DB\s0 package, caller returns more
|
757
|
+
detailed information: it sets the list variable \f(CW@DB::args\fR to be the
|
758
|
+
arguments with which the subroutine was invoked.
|
759
|
+
.Sp
|
760
|
+
Be aware that the optimizer might have optimized call frames away before
|
761
|
+
\&\f(CW\*(C`caller\*(C'\fR had a chance to get the information. That means that \f(CWcaller(N)\fR
|
762
|
+
might not return information about the call frame you expect it do, for
|
763
|
+
\&\f(CW\*(C`N > 1\*(C'\fR. In particular, \f(CW@DB::args\fR might have information from the
|
764
|
+
previous time \f(CW\*(C`caller\*(C'\fR was called.
|
765
|
+
.IP "chdir \s-1EXPR\s0" 8
|
766
|
+
.IX Xref "chdir cd"
|
767
|
+
.IX Item "chdir EXPR"
|
768
|
+
.PD 0
|
769
|
+
.IP "chdir \s-1FILEHANDLE\s0" 8
|
770
|
+
.IX Item "chdir FILEHANDLE"
|
771
|
+
.IP "chdir \s-1DIRHANDLE\s0" 8
|
772
|
+
.IX Item "chdir DIRHANDLE"
|
773
|
+
.IP "chdir" 8
|
774
|
+
.IX Item "chdir"
|
775
|
+
.PD
|
776
|
+
Changes the working directory to \s-1EXPR\s0, if possible. If \s-1EXPR\s0 is omitted,
|
777
|
+
changes to the directory specified by \f(CW$ENV{HOME}\fR, if set; if not,
|
778
|
+
changes to the directory specified by \f(CW$ENV{LOGDIR}\fR. (Under \s-1VMS\s0, the
|
779
|
+
variable \f(CW$ENV{SYS$LOGIN}\fR is also checked, and used if it is set.) If
|
780
|
+
neither is set, \f(CW\*(C`chdir\*(C'\fR does nothing. It returns true upon success,
|
781
|
+
false otherwise. See the example under \f(CW\*(C`die\*(C'\fR.
|
782
|
+
.Sp
|
783
|
+
On systems that support fchdir, you might pass a file handle or
|
784
|
+
directory handle as argument. On systems that don't support fchdir,
|
785
|
+
passing handles produces a fatal error at run time.
|
786
|
+
.IP "chmod \s-1LIST\s0" 8
|
787
|
+
.IX Xref "chmod permission mode"
|
788
|
+
.IX Item "chmod LIST"
|
789
|
+
Changes the permissions of a list of files. The first element of the
|
790
|
+
list must be the numerical mode, which should probably be an octal
|
791
|
+
number, and which definitely should \fInot\fR be a string of octal digits:
|
792
|
+
\&\f(CW0644\fR is okay, \f(CW'0644'\fR is not. Returns the number of files
|
793
|
+
successfully changed. See also \*(L"oct\*(R", if all you have is a string.
|
794
|
+
.Sp
|
795
|
+
.Vb 6
|
796
|
+
\& $cnt = chmod 0755, 'foo', 'bar';
|
797
|
+
\& chmod 0755, @executables;
|
798
|
+
\& $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to
|
799
|
+
\& # --w----r-T
|
800
|
+
\& $mode = '0644'; chmod oct($mode), 'foo'; # this is better
|
801
|
+
\& $mode = 0644; chmod $mode, 'foo'; # this is best
|
802
|
+
.Ve
|
803
|
+
.Sp
|
804
|
+
On systems that support fchmod, you might pass file handles among the
|
805
|
+
files. On systems that don't support fchmod, passing file handles
|
806
|
+
produces a fatal error at run time.
|
807
|
+
.Sp
|
808
|
+
.Vb 3
|
809
|
+
\& open(my $fh, "<", "foo");
|
810
|
+
\& my $perm = (stat $fh)[2] & 07777;
|
811
|
+
\& chmod($perm | 0600, $fh);
|
812
|
+
.Ve
|
813
|
+
.Sp
|
814
|
+
You can also import the symbolic \f(CW\*(C`S_I*\*(C'\fR constants from the Fcntl
|
815
|
+
module:
|
816
|
+
.Sp
|
817
|
+
.Vb 1
|
818
|
+
\& use Fcntl ':mode';
|
819
|
+
.Ve
|
820
|
+
.Sp
|
821
|
+
.Vb 2
|
822
|
+
\& chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
|
823
|
+
\& # This is identical to the chmod 0755 of the above example.
|
824
|
+
.Ve
|
825
|
+
.IP "chomp \s-1VARIABLE\s0" 8
|
826
|
+
.IX Xref "chomp INPUT_RECORD_SEPARATOR $ newline eol"
|
827
|
+
.IX Item "chomp VARIABLE"
|
828
|
+
.PD 0
|
829
|
+
.IP "chomp( \s-1LIST\s0 )" 8
|
830
|
+
.IX Item "chomp( LIST )"
|
831
|
+
.IP "chomp" 8
|
832
|
+
.IX Item "chomp"
|
833
|
+
.PD
|
834
|
+
This safer version of \*(L"chop\*(R" removes any trailing string
|
835
|
+
that corresponds to the current value of \f(CW$/\fR (also known as
|
836
|
+
\&\f(CW$INPUT_RECORD_SEPARATOR\fR in the \f(CW\*(C`English\*(C'\fR module). It returns the total
|
837
|
+
number of characters removed from all its arguments. It's often used to
|
838
|
+
remove the newline from the end of an input record when you're worried
|
839
|
+
that the final record may be missing its newline. When in paragraph
|
840
|
+
mode (\f(CW\*(C`$/ = ""\*(C'\fR), it removes all trailing newlines from the string.
|
841
|
+
When in slurp mode (\f(CW\*(C`$/ = undef\*(C'\fR) or fixed-length record mode (\f(CW$/\fR is
|
842
|
+
a reference to an integer or the like, see perlvar) \fIchomp()\fR won't
|
843
|
+
remove anything.
|
844
|
+
If \s-1VARIABLE\s0 is omitted, it chomps \f(CW$_\fR. Example:
|
845
|
+
.Sp
|
846
|
+
.Vb 5
|
847
|
+
\& while (<>) {
|
848
|
+
\& chomp; # avoid \en on last field
|
849
|
+
\& @array = split(/:/);
|
850
|
+
\& # ...
|
851
|
+
\& }
|
852
|
+
.Ve
|
853
|
+
.Sp
|
854
|
+
If \s-1VARIABLE\s0 is a hash, it chomps the hash's values, but not its keys.
|
855
|
+
.Sp
|
856
|
+
|