summaryrefslogtreecommitdiff
path: root/pod/perlfaq5.pod
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-08-17 15:57:09 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-08-17 15:57:09 +0000
commitb68463f7111b76264d78b38de603c7c4a3c5e635 (patch)
tree7b5153ce44a42fc4841ed7592ea2e01baf4f3c4b /pod/perlfaq5.pod
parent93a047328e714ace2986c9ffb3515b4bf0939bfd (diff)
downloadperl-b68463f7111b76264d78b38de603c7c4a3c5e635.tar.gz
FAQ sync
p4raw-id: //depot/perl@25301
Diffstat (limited to 'pod/perlfaq5.pod')
-rw-r--r--pod/perlfaq5.pod32
1 files changed, 17 insertions, 15 deletions
diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod
index 45a1aa8c50..85f1c546e5 100644
--- a/pod/perlfaq5.pod
+++ b/pod/perlfaq5.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq5 - Files and Formats ($Revision: 1.36 $, $Date: 2005/04/22 19:04:48 $)
+perlfaq5 - Files and Formats ($Revision: 1.37 $, $Date: 2005/08/10 15:55:23 $)
=head1 DESCRIPTION
@@ -339,6 +339,13 @@ See L<perlform/"Accessing Formatting Internals"> for an swrite() function.
=head2 How can I output my numbers with commas added?
+(contributed by brian d foy and Benjamin Goldberg)
+
+You can use L<Number::Format> to separate places in a number.
+It handles locale information for those of you who want to insert
+full stops instead (or anything else that they want to use,
+really).
+
This subroutine will add commas to your number:
sub commify {
@@ -482,25 +489,20 @@ best therefore to use glob() only in list context.
=head2 How can I open a file with a leading ">" or trailing blanks?
-Normally perl ignores trailing blanks in filenames, and interprets
-certain leading characters (or a trailing "|") to mean something
-special.
+(contributed by Brian McCauley)
-The three argument form of open() lets you specify the mode
-separately from the filename. The open() function treats
-special mode characters and whitespace in the filename as
-literals
+The special two argument form of Perl's open() function ignores
+trailing blanks in filenames and infers the mode from certain leading
+characters (or a trailing "|"). In older versions of Perl this was the
+only version of open() and so it is prevalent in old code and books.
+Unless you have a particular reason to use the two argument form you
+should use the three argument form of open() which does not treat any
+charcters in the filename as special.
+
open FILE, "<", " file "; # filename is " file "
open FILE, ">", ">file"; # filename is ">file"
-It may be a lot clearer to use sysopen(), though:
-
- use Fcntl;
- $badpath = "<<<something really wicked ";
- sysopen (FH, $badpath, O_WRONLY | O_CREAT | O_TRUNC)
- or die "can't open $badpath: $!";
-
=head2 How can I reliably rename a file?
If your operating system supports a proper mv(1) utility or its