Changeset 13649 for docs/Perl6/Spec
- Timestamp:
- 09/26/06 02:17:04 (2 years ago)
- Files:
-
- 1 modified
-
docs/Perl6/Spec/IO.pod (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/Perl6/Spec/IO.pod
r13388 r13649 12 12 Contributions: Mark Stosberg <mark@summersault.com> 13 13 Date: 12 Sep 2006 14 Last Modified: 17Sep 200615 Version: 1 414 Last Modified: 25 Sep 2006 15 Version: 15 16 16 17 17 This is a draft document. Many of these functions will work as in Perl 5, … … 43 43 A file test, where X is one of the letters listed below. This unary 44 44 operator takes one argument, either a filename or a filehandle, and 45 tests the associated file to see if something is true about it. If the 46 argument is omitted, tests C<$_>, except for C<-t>, which tests STDIN. 47 Unless otherwise documented, it returns C<1> for true and C<''> for false, or 48 the undefined value if the file doesn't exist. Despite the funny 45 tests the associated file to see if something is true about it. 46 The argument may not be omitted unless it is C<$_>, in which case you must 47 use the C<.'-X'> form. 48 49 All file test operators return a stat buffer that also carries a "cumulative 50 success" boolean (or file size in the case of C<-s>) so that tests may be stacked: 51 52 -r -w $filename 53 54 or applied to existing stat buffers: 55 56 $b = stat($filename); 57 if -r $b {...} 58 59 Despite the funny 49 60 names, precedence is the same as any other named unary operator, and 50 61 the argument may be parenthesized like any other unary operator. The … … 140 151 list must be the numerical mode, which should probably be an octal 141 152 number, and which definitely should I<not> be a string of octal digits: 142 C<0644> is okay, C<'0644'> is not. Returns the number of files 143 successfully changed. See also L</oct>, if all you have is a string. 144 145 $cnt = chmod 0755, 'foo', 'bar'; 146 chmod 0755, @executables; 147 $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to 148 # --w----r-T 149 $mode = '0644'; chmod oct($mode), 'foo'; # this is better 150 $mode = 0644; chmod $mode, 'foo'; # this is best 153 C<0o644> is okay, C<0644> is not. Returns the number of files 154 successfully changed. 155 156 $cnt = chmod 0o755, 'foo', 'bar'; 157 chmod 0o755, @executables; 158 $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T 159 $mode = '0o644'; chmod $mode, 'foo'; # this is better 160 $mode = 0o644; chmod $mode, 'foo'; # this is best 151 161 152 162 =item close FILEHANDLE … … 197 207 =item lstat 198 208 209 Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates 210 to true, and additional file tests may be performed on the value. If 211 the stat fails, all subsequent tests on the stat buffer also evaluate 212 to false. 213 199 214 =item mkdir 200 215 … … 251 266 252 267 =item stat 268 269 Returns a stat buffer. If the lstat succeeds, the stat buffer evaluates 270 to true, and additional file tests may be performed on the value. If 271 the stat fails, all subsequent tests on the stat buffer also evaluate 272 to false. 253 273 254 274 =item symlink … … 366 386 =item binmode 367 387 388 =item lines 389 390 our List multi method lines (IO $handle:) is export; 391 our List multi lines (Str $filename); 392 393 Returns all the lines of a file as a (lazy) List regardless of context. 394 See also C<slurp>. 395 368 396 =item pipe 369 397 … … 389 417 390 418 =item slurp 419 420 our Item multi method slurp (IO $handle: *%opts) is export; 421 our Item multi slurp (Str $filename, *%opts); 422 423 Slurps the entire file into a Str or Buf regardless of context. 424 (See also C<lines>.) Whether a Str or Buf is returneded depends on 425 the options. 391 426 392 427 =item socket
