From: Gurusamy Sarathy Date: Tue, 28 Dec 1999 20:42:13 +0000 (+0000) Subject: tests for change#4642 and pod fixups suggested by Ralph Corderoy X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=820475bd7227fcbc2178bb45a4d501c4ccc2133b;p=p5sagit%2Fp5-mst-13.2.git tests for change#4642 and pod fixups suggested by Ralph Corderoy p4raw-link: @4642 on //depot/perl: db7ec62399075c965a182629c9ca8ed4044fc594 p4raw-id: //depot/perl@4732 --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index c5f3a30..e7aac32 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -775,6 +775,12 @@ on C will return the same data as the corresponding operation on C. Formerly, it would have returned the data from the start of the following disk block instead. +=head2 eof() has the same old magic as <> + +C would return true if no attempt to read from CE> had +yet been made. C has been changed to have a little magic of its +own, it now opens the CE> files. + =head2 system(), backticks and pipe open now reflect exec() failure On Unix and similar platforms, system(), qx() and open(FOO, "cmd |") diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index e5652ef..c1bc4c5 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1172,13 +1172,17 @@ interactive context.) Do not read from a terminal file (or call C on it) after end-of-file is reached. File types such as terminals may lose the end-of-file condition if you do. -An C without an argument uses the last file read as argument. -Using C with empty parentheses is very different. It indicates -the pseudo file formed of the files listed on the command line, -i.e., C is reasonable to use inside a CE)> -loop to detect the end of only the last file. Use C or -C without the parentheses to test I file in a while -(EE) loop. Examples: +An C without an argument uses the last file read. Using C +with empty parentheses is very different. It refers to the pseudo file +formed from the files listed on the command line and accessed via the +CE> operator. Since CE> isn't explicitly opened, +as a normal filehandle is, an C before CE> has been +used will cause C<@ARGV> to be examined to determine if input is +available. + +In a CE)> loop, C or C can be used to +detect the end of each file, C will only detect the end of the +last file. Examples: # reset line numbering on each input file while (<>) { diff --git a/pod/perlre.pod b/pod/perlre.pod index 9c88a0b..70ec00c 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -121,7 +121,7 @@ to integral values less than a preset limit defined when perl is built. This is usually 32766 on the most common platforms. The actual limit can be seen in the error message generated by code such as this: - $_ **= $_ , / {$_} / for 2 .. 42; + $_ **= $_ , / {$_} / for 2 .. 42; By default, a quantified subpattern is "greedy", that is, it will match as many times as possible (given a particular starting location) while still @@ -191,7 +191,7 @@ See L for details about C<\pP>, C<\PP>, and C<\X>. The POSIX character class syntax - [:class:] + [:class:] is also available. The available classes and their backslash equivalents (if available) are as follows: @@ -214,7 +214,7 @@ For example use C<[:upper:]> to match all the uppercase characters. Note that the C<[]> are part of the C<[::]> construct, not part of the whole character class. For example: - [01[:alpha:]%] + [01[:alpha:]%] matches one, zero, any alphabetic character, and the percentage sign. @@ -247,29 +247,27 @@ The assumedly non-obviously named classes are: =item cntrl - Any control character. Usually characters that don't produce - output as such but instead control the terminal somehow: - for example newline and backspace are control characters. - All characters with ord() less than 32 are most often control - classified as characters. +Any control character. Usually characters that don't produce output as +such but instead control the terminal somehow: for example newline and +backspace are control characters. All characters with ord() less than +32 are most often control classified as characters. =item graph - Any alphanumeric or punctuation character. +Any alphanumeric or punctuation character. =item print - Any alphanumeric or punctuation character or space. +Any alphanumeric or punctuation character or space. =item punct - Any punctuation character. +Any punctuation character. =item xdigit - Any hexadecimal digit. Though this may feel silly - (/0-9a-f/i would work just fine) it is included - for completeness. +Any hexadecimal digit. Though this may feel silly (/0-9a-f/i would +work just fine) it is included for completeness. =item diff --git a/t/io/argv.t b/t/io/argv.t index c6565dc..3695e8a 100755 --- a/t/io/argv.t +++ b/t/io/argv.t @@ -1,6 +1,15 @@ #!./perl -print "1..6\n"; +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +print "1..14\n"; + +use File::Spec; + +my $devnull = File::Spec->devnull; open(try, '>Io.argv.tmp') || (die "Can't open temp file: $!"); print try "a line\n"; @@ -30,7 +39,7 @@ else { } if ($x eq "foo\n") {print "ok 3\n";} else {print "not ok 3 :$x:\n";} -@ARGV = ('Io.argv.tmp', 'Io.argv.tmp', '/dev/null', 'Io.argv.tmp'); +@ARGV = ('Io.argv.tmp', 'Io.argv.tmp', $devnull, 'Io.argv.tmp'); while (<>) { $y .= $. . $_; if (eof()) { @@ -55,5 +64,37 @@ while (<>) { open(try, '; close try; +undef $^I; + +eof try or print 'not '; +print "ok 7\n"; + +eof NEVEROPENED or print 'not '; +print "ok 8\n"; + +open STDIN, 'Io.argv.tmp' or die $!; +@ARGV = (); +!eof() or print 'not '; +print "ok 9\n"; + +<> eq "ok 6\n" or print 'not '; +print "ok 10\n"; + +open STDIN, $devnull or die $!; +@ARGV = (); +eof() or print 'not '; +print "ok 11\n"; + +@ARGV = ('Io.argv.tmp'); +!eof() or print 'not '; +print "ok 12\n"; + +@ARGV = ($devnull, $devnull); +!eof() or print 'not '; +print "ok 13\n"; + +close ARGV or die $!; +eof() or print 'not '; +print "ok 14\n"; END { unlink 'Io.argv.tmp', 'Io.argv.tmp.bak' }