home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / IO::File.z / IO::File
Encoding:
Text File  |  1998-10-30  |  3.8 KB  |  133 lines

  1.  
  2.  
  3.  
  4. IIIIOOOO::::::::FFFFiiiilllleeee((((3333))))                                                        IIIIOOOO::::::::FFFFiiiilllleeee((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      IO::File - supply object methods for filehandles
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use IO::File;
  13.  
  14.          $fh = new IO::File;
  15.          if ($fh->open("< file")) {
  16.              print <$fh>;
  17.              $fh->close;
  18.          }
  19.  
  20.          $fh = new IO::File "> file";
  21.          if (defined $fh) {
  22.              print $fh "bar\n";
  23.              $fh->close;
  24.          }
  25.  
  26.          $fh = new IO::File "file", "r";
  27.          if (defined $fh) {
  28.              print <$fh>;
  29.              undef $fh;       # automatically closes the file
  30.          }
  31.  
  32.          $fh = new IO::File "file", O_WRONLY|O_APPEND;
  33.          if (defined $fh) {
  34.              print $fh "corge\n";
  35.  
  36.              $pos = $fh->getpos;
  37.              $fh->setpos($pos);
  38.  
  39.              undef $fh;       # automatically closes the file
  40.          }
  41.  
  42.          autoflush STDOUT 1;
  43.  
  44.  
  45. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  46.      IO::File inherits from IO::Handle and IO::Seekable. It extends these
  47.      classes with methods that are specific to file handles.
  48.  
  49. CCCCOOOONNNNSSSSTTTTRRRRUUUUCCCCTTTTOOOORRRR
  50.      new ([ ARGS ] )
  51.          Creates a IO::File.  If it receives any parameters, they are passed
  52.          to the method open; if the open fails, the object is destroyed.
  53.          Otherwise, it is returned to the caller.
  54.  
  55.      new_tmpfile
  56.          Creates an IO::File opened for read/write on a newly created
  57.          temporary file.  On systems where this is possible, the temporary
  58.          file is anonymous (i.e. it is unlinked after creation, but held
  59.          open).  If the temporary file cannot be created or opened, the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. IIIIOOOO::::::::FFFFiiiilllleeee((((3333))))                                                        IIIIOOOO::::::::FFFFiiiilllleeee((((3333))))
  71.  
  72.  
  73.  
  74.          IO::File object is destroyed.  Otherwise, it is returned to the
  75.          caller.
  76.  
  77. MMMMEEEETTTTHHHHOOOODDDDSSSS
  78.      open( FILENAME [,MODE [,PERMS]] )
  79.          open accepts one, two or three parameters.  With one parameter, it is
  80.          just a front end for the built-in open function.  With two
  81.          parameters, the first parameter is a filename that may include
  82.          whitespace or other special characters, and the second parameter is
  83.          the open mode, optionally followed by a file permission value.
  84.  
  85.          If IO::File::open receives a Perl mode string (">", "+<", etc.)  or a
  86.          POSIX _f_o_p_e_n() mode string ("w", "r+", etc.), it uses the basic Perl
  87.          open operator.
  88.  
  89.          If IO::File::open is given a numeric mode, it passes that mode and
  90.          the optional permissions value to the Perl sysopen operator.  For
  91.          convenience, IO::File::import tries to import the O_XXX constants
  92.          from the Fcntl module.  If dynamic loading is not available, this may
  93.          fail, but the rest of IO::File will still work.
  94.  
  95. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  96.      the _p_e_r_l_f_u_n_c manpage, the section on _I/_O _O_p_e_r_a_t_o_r_s in the _p_e_r_l_o_p manpage,
  97.      the _I_O::_H_a_n_d_l_e manpage the _I_O::_S_e_e_k_a_b_l_e manpage
  98.  
  99. HHHHIIIISSSSTTTTOOOORRRRYYYY
  100.      Derived from FileHandle.pm by Graham Barr <_b_o_d_g@_t_i_u_k._t_i._c_o_m>.
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.