cvs commit: perlfaq perlfaq5.pod
[email protected] (brian d foy) 21 Jan 2005 12:26:11 -0000
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 05/01/21 04:26:11
Modified: . perlfaq5.pod
Log:
* How can I output my numbers with commas added?
+ fixed regex difference between Benjamin's uncommented
and commented substitution. Identified by Hendrik Maryns.
Revision Changes Path
1.35 +18 -2 perlfaq/perlfaq5.pod
Index: perlfaq5.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq5.pod,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- perlfaq5.pod 3 Jan 2005 18:43:37 -0000 1.34
+++ perlfaq5.pod 21 Jan 2005 12:26:11 -0000 1.35
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq5 - Files and Formats ($Revision: 1.34 $, $Date: 2005/01/03 18:43:37 $)
+perlfaq5 - Files and Formats ($Revision: 1.35 $, $Date: 2005/01/21 12:26:11 $)
=head1 DESCRIPTION
@@ -106,6 +106,22 @@
leaving a backup of the original data from each file in a new
C<.c.orig> file.
+=head2 How can I copy a file?
+
+(contributed by brian d foy)
+
+Use the File::Copy module. It comes with Perl and can do a
+true copy across file systems, and it does its magic in
+a portable fashion.
+
+ use File::Copy;
+
+ copy( $original, $new_copy ) or die "Copy failed: $!";
+
+If you can't use File::Copy, you'll have to do the work yourself:
+open the original file, open the destination file, then print
+to the destination file as you read the original.
+
=head2 How do I make a temporary file name?
If you don't need to know the name of the file, you can use C<open()>
@@ -339,7 +355,7 @@
s/(
^[-+]? # beginning of number.
- \d{1,3}? # first digits before first comma
+ \d+? # first digits before first comma
(?= # followed by, (but not included in the match) :
(?>(?:\d{3})+) # some positive multiple of three digits.
(?!\d) # an *exact* multiple, not x * 3 + 1 or whatever.