text files. If FILEHANDLE is an expression, the value is taken as the
name of the filehandle. DISCIPLINE can be either of C<":raw"> for
binary mode or C<":crlf"> for "text" mode. If the DISCIPLINE is
-omitted, it defaults to C<":raw">.
+omitted, it defaults to C<":raw">. Returns true on success, C<undef> on
+failure.
binmode() should be called after open() but before any I/O is done on
the filehandle.
-On many systems binmode() currently has no effect, but in future, it
-will be extended to support user-defined input and output disciplines.
On some systems binmode() is necessary when you're not working with a
text file. For the sake of portability it is a good idea to always use
it when appropriate, and to never use it when it isn't appropriate.
Returns the character represented by that NUMBER in the character set.
For example, C<chr(65)> is C<"A"> in either ASCII or Unicode, and
-chr(0x263a) is a Unicode smiley face. Within the scope of C<use utf8>,
-characters higher than 127 are encoded in Unicode; if you don't want
-this, temporarily C<use bytes> or use C<pack("C*",...)>
+chr(0x263a) is a Unicode smiley face. Note that characters from
+127 to 255 (inclusive) are not encoded in Unicode for backward
+compatibility reasons.
For the reverse, use L</ord>.
See L<utf8> for more about Unicode.
=item lc
Returns an lowercased version of EXPR. This is the internal function
-implementing the C<\L> escape in double-quoted strings.
-Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>
-and L<utf8>.
+implementing the C<\L> escape in double-quoted strings. Respects
+current LC_CTYPE locale if C<use locale> in force. See L<perllocale>
+and L<perlunicode>.
If EXPR is omitted, uses C<$_>.
=item lcfirst
-Returns the value of EXPR with the first character lowercased. This is
-the internal function implementing the C<\l> escape in double-quoted strings.
-Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>.
+Returns the value of EXPR with the first character lowercased. This
+is the internal function implementing the C<\l> escape in
+double-quoted strings. Respects current LC_CTYPE locale if C<use
+locale> in force. See L<perllocale> and L<perlunicode>.
If EXPR is omitted, uses C<$_>.
P A pointer to a structure (fixed-length string).
u A uuencoded string.
- U A Unicode character number. Encodes to UTF-8 internally.
- Works even if C<use utf8> is not in effect.
+ U A Unicode character number. Encodes to UTF-8 internally
+ (or UTF-EBCDIC in EBCDIC platforms).
w A BER compressed integer. Its bytes represent an unsigned
integer in base 128, most significant digit first, with as
eval "require $class";
+You can also insert hooks into the import facility, by putting directly
+Perl code into the @INC array. There are three forms of hooks: subroutine
+references, array references and blessed objects.
+
+Subroutine references are the simplest case. When the inclusion system
+walks through @INC and encounters a subroutine, this subroutine gets
+called with two parameters, the first being a reference to itself, and the
+second the name of the file to be included (e.g. "F<Foo/Bar.pm>"). The
+subroutine should return C<undef> or a filehandle, from which the file to
+include will be read. If C<undef> is returned, C<require> will look at
+the remaining elements of @INC.
+
+If the hook is an array reference, its first element must be a subroutine
+reference. This subroutine is called as above, but the first parameter is
+the array reference. This enables to pass indirectly some arguments to
+the subroutine.
+
+In other words, you can write:
+
+ push @INC, \&my_sub;
+ sub my_sub {
+ my ($coderef, $filename) = @_; # $coderef is \&my_sub
+ ...
+ }
+
+or:
+
+ push @INC, [ \&my_sub, $x, $y, ... ];
+ sub my_sub {
+ my ($arrayref, $filename) = @_;
+ # Retrieve $x, $y, ...
+ my @parameters = @$arrayref[1..$#$arrayref];
+ ...
+ }
+
+If the hook is an object, it must provide an INC method, that will be
+called as above, the first parameter being the object itself. (Note that
+you must fully qualify the sub's name, as it is always forced into package
+C<main>.) Here is a typical code layout:
+
+ # In Foo.pm
+ package Foo;
+ sub new { ... }
+ sub Foo::INC {
+ my ($self, $filename) = @_;
+ ...
+ }
+
+ # In the main program
+ push @INC, new Foo(...);
+
For a yet-more-powerful import facility, see L</use> and L<perlmod>.
=item reset EXPR
produces the output 'h:i:t:h:e:r:e'.
+Using the empty pattern C<//> specifically matches the null string, and is
+not be confused with the use of C<//> to mean "the last successful pattern
+match".
+
Empty leading (or trailing) fields are produced when there positive width
matches at the beginning (or end) of the string; a zero-width match at the
beginning (or end) of the string does not produce an empty field. For
#...
}
+As with regular pattern matching, any capturing parentheses that are not
+matched in a C<split()> will be set to C<undef> when returned:
+
+ @fields = split /(A)|B/, "1A2B3";
+ # @fields is (1, 'A', 2, undef, 3)
=item sprintf FORMAT, LIST
=item uc
Returns an uppercased version of EXPR. This is the internal function
-implementing the C<\U> escape in double-quoted strings.
-Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>.
-Under Unicode (C<use utf8>) it uses the standard Unicode uppercase mappings. (It
-does not attempt to do titlecase mapping on initial letters. See C<ucfirst> for that.)
+implementing the C<\U> escape in double-quoted strings. Respects
+current LC_CTYPE locale if C<use locale> in force. See L<perllocale>
+and L<perlunicode>. Under Unicode it uses the standard Unicode
+uppercase mappings. (It does not attempt to do titlecase mapping on
+initial letters. See C<ucfirst> for that.)
If EXPR is omitted, uses C<$_>.
=item ucfirst
-Returns the value of EXPR with the first character
-in uppercase (titlecase in Unicode). This is
-the internal function implementing the C<\u> escape in double-quoted strings.
-Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>
-and L<utf8>.
+Returns the value of EXPR with the first character in uppercase
+(titlecase in Unicode). This is the internal function implementing
+the C<\u> escape in double-quoted strings. Respects current LC_CTYPE
+locale if C<use locale> in force. See L<perllocale> and L<perlunicode>.
If EXPR is omitted, uses C<$_>.
use POSIX ":sys_wait_h";
#...
do {
- $kid = waitpid(-1,&WNOHANG);
+ $kid = waitpid(-1, WNOHANG);
} until $kid == -1;
then you can do a non-blocking wait for all pending zombie processes.