home *** CD-ROM | disk | FTP | other *** search
-
-
-
- FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333))))
-
-
-
- NNNNAAAAMMMMEEEE
- File::Copy - Copy files or filehandles
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- use File::Copy;
-
- copy("file1","file2");
- copy("Copy.pm",\*STDOUT);'
- move("/dev1/fileA","/dev2/fileB");
-
- use POSIX;
- use File::Copy cp;
-
- $n=FileHandle->new("/dev/null","r");
- cp($n,"x");'
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- The File::Copy module provides two basic functions, copy and
- move, which are useful for getting the contents of a file
- from one place to another.
-
- +o The copy function takes two parameters: a file to copy
- from and a file to copy to. Either argument may be a
- string, a FileHandle reference or a FileHandle glob.
- Obviously, if the first argument is a filehandle of some
- sort, it will be read from, and if it is a file _n_a_m_e it
- will be opened for reading. Likewise, the second
- argument will be written to (and created if need be).
-
- NNNNooootttteeee tttthhhhaaaatttt ppppaaaassssssssiiiinnnngggg iiiinnnn ffffiiiilllleeeessss aaaassss hhhhaaaannnnddddlllleeeessss iiiinnnnsssstttteeeeaaaadddd ooooffff nnnnaaaammmmeeeessss
- mmmmaaaayyyy lllleeeeaaaadddd ttttoooo lllloooossssssss ooooffff iiiinnnnffffoooorrrrmmmmaaaattttiiiioooonnnn oooonnnn ssssoooommmmeeee ooooppppeeeerrrraaaattttiiiinnnngggg
- ssssyyyysssstttteeeemmmmssss;;;; iiiitttt iiiissss rrrreeeeccccoooommmmmmmmeeeennnnddddeeeedddd tttthhhhaaaatttt yyyyoooouuuu uuuusssseeee ffffiiiilllleeee nnnnaaaammmmeeeessss
- wwwwhhhheeeennnneeeevvvveeeerrrr ppppoooossssssssiiiibbbblllleeee.... Files are opened in binary mode
- where applicable. To get a consistent behavour when
- copying from a filehandle to a file, use binmode on the
- filehandle.
-
- An optional third parameter can be used to specify the
- buffer size used for copying. This is the number of
- bytes from the first file, that wil be held in memory at
- any given time, before being written to the second file.
- The default buffer size depends upon the file, but will
- generally be the whole file (up to 2Mb), or 1k for
- filehandles that do not reference files (eg. sockets).
-
- You may use the syntax use File::Copy "cp" to get at the
- "cp" alias for this function. The syntax is _e_x_a_c_t_l_y the
- same.
-
- +o The move function also takes two parameters: the current
- name and the intended name of the file to be moved. If
-
-
-
- Page 1 (printed 10/23/98)
-
-
-
-
-
-
- FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333))))
-
-
-
- the destination already exists and is a directory, and
- the source is not a directory, then the source file will
- be renamed into the directory specified by the
- destination.
-
- If possible, _m_o_v_e() will simply rename the file.
- Otherwise, it copies the file to the new location and
- deletes the original. If an error occurs during this
- copy-and-delete process, you may be left with a
- (possibly partial) copy of the file under the
- destination name.
-
- You may use the "mv" alias for this function in the same
- way that you may use the "cp" alias for copy.
-
- File::Copy also provides the syscopy routine, which copies
- the file specified in the first parameter to the file
- specified in the second parameter, preserving OS-specific
- attributes and file structure. For Unix systems, this is
- equivalent to the simple copy routine. For VMS systems,
- this calls the rmscopy routine (see below). For OS/2
- systems, this calls the syscopy XSUB directly.
-
- SSSSppppeeeecccciiiiaaaallll bbbbeeeehhhhaaaavvvviiiioooorrrr iiiiffff ssssyyyyssssccccooooppppyyyy is defined (VMS and OS/2)
-
- If both arguments to copy are not file handles, then copy
- will perform a "system copy" of the input file to a new
- output file, in order to preserve file attributes, indexed
- file structure, _e_t_c. The buffer size parameter is ignored.
- If either argument to copy is a handle to an opened file,
- then data is copied using Perl operators, and no effort is
- made to preserve file attributes or record structure.
-
- The system copy routine may also be called directly under
- VMS and OS/2 as File::Copy::syscopy (or under VMS as
- File::Copy::rmscopy, which is the routine that does the
- actual work for syscopy).
-
- rmscopy($from,$to[,$date_flag])
- The first and second arguments may be strings,
- typeglobs, typeglob references, or objects inheriting
- from IO::Handle; they are used in all cases to obtain
- the _f_i_l_e_s_p_e_c of the input and output files,
- respectively. The name and type of the input file are
- used as defaults for the output file, if necessary.
-
- A new version of the output file is always created,
- which inherits the structure and RMS attributes of the
- input file, except for owner and protections (and
- possibly timestamps; see below). All data from the
- input file is copied to the output file; if either of
- the first two parameters to rmscopy is a file handle,
-
-
-
- Page 2 (printed 10/23/98)
-
-
-
-
-
-
- FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) FFFFiiiilllleeee::::::::CCCCooooppppyyyy((((3333))))
-
-
-
- its position is unchanged. (Note that this means a file
- handle pointing to the output file will be associated
- with an old version of that file after rmscopy returns,
- not the newly created version.)
-
- The third parameter is an integer flag, which tells
- rmscopy how to handle timestamps. If it is < 0, none of
- the input file's timestamps are propagated to the output
- file. If it is > 0, then it is interpreted as a
- bitmask: if bit 0 (the LSB) is set, then timestamps
- other than the revision date are propagated; if bit 1 is
- set, the revision date is propagated. If the third
- parameter to rmscopy is 0, then it behaves much like the
- DCL COPY command: if the name or type of the output
- file was explicitly specified, then no timestamps are
- propagated, but if they were taken implicitly from the
- input filespec, then all timestamps other than the
- revision date are propagated. If this parameter is not
- supplied, it defaults to 0.
-
- Like copy, rmscopy returns 1 on success. If an error
- occurs, it sets $!, deletes the output file, and returns
- 0.
-
- RRRREEEETTTTUUUURRRRNNNN
- All functions return 1 on success, 0 on failure. $! will be
- set if an error was encountered.
-
- AAAAUUUUTTTTHHHHOOOORRRR
- File::Copy was written by Aaron Sherman <_a_j_s@_a_j_s._c_o_m> in
- 1995, and updated by Charles Bailey
- <_b_a_i_l_e_y@_g_e_n_e_t_i_c_s._u_p_e_n_n._e_d_u> in 1996.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 3 (printed 10/23/98)
-
-
-
-