Hash lookup of constant strings optimization:
[p5sagit/p5-mst-13.2.git] / pod / perlfaq4.pod
index 838f753..79905f8 100644 (file)
@@ -282,8 +282,8 @@ and Date::Manip modules from CPAN.
 
 =head2 How can I find the Julian Day?
 
-You could use Date::Calc's Delta_Days function and calculate the number
-of days from there.  Assuming that's what you really want, that is.
+Use the Time::JulianDay module (part of the Time-modules bundle
+available from CPAN.)
 
 Before you immerse yourself too deeply in this, be sure to verify that it
 is the I<Julian> Day you really want.  Are they really just interested in
@@ -301,9 +301,6 @@ world and 1980 in the MS-DOS/Windows world.  If you find that it is not
 the first meaning that you really want, then check out the Date::Manip
 and Date::Calc modules.  (Thanks to David Cassell for most of this text.)
 
-There is also an example of Julian date calculation that should help you in
-http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/JulianDay.pm.gz
-
 =head2 How do I find yesterday's date?
 
 The C<time()> function returns the current time in seconds since the
@@ -373,7 +370,7 @@ you can.  Is that the pencil's fault?  Of course it isn't.
 The date and time functions supplied with Perl (gmtime and localtime)
 supply adequate information to determine the year well beyond 2000
 (2038 is when trouble strikes for 32-bit machines).  The year returned
-by these functions when used in an array context is the year minus 1900.
+by these functions when used in a list context is the year minus 1900.
 For years between 1910 and 1999 this I<happens> to be a 2-digit decimal
 number. To avoid the year 2000 problem simply do not treat the year as
 a 2-digit number.  It isn't.
@@ -447,11 +444,9 @@ nested patterns, nor can they.  For that you'll have to write a
 parser.
 
 If you are serious about writing a parser, there are a number of
-modules or oddities that will make your life a lot easier.  There is
-the CPAN module Parse::RecDescent, the standard module Text::Balanced,
-the byacc program, the CPAN module Parse::Yapp, and Mark-Jason
-Dominus's excellent I<py> tool at http://www.plover.com/%7Emjd/perl/py/
-.
+modules or oddities that will make your life a lot easier.  There are
+the CPAN modules Parse::RecDescent, Parse::Yapp, and Text::Balanced;
+and the byacc program.
 
 One simple destructive, inside-out approach that you might try is to
 pull out the smallest nesting parts one at a time:
@@ -468,7 +463,7 @@ really does work:
     # $_ contains the string to parse
     # BEGIN and END are the opening and closing markers for the
     # nested text.
+
     @( = ('(','');
     @) = (')','');
     ($re=$_)=~s/((BEGIN)|(END)|.)/$)[!$3]\Q$1\E$([!$2]/gs;
@@ -824,7 +819,7 @@ Stringification also destroys arrays.
     print "@lines";            # WRONG - extra blanks
     print @lines;              # right
 
-=head2 Why don't my E<lt>E<lt>HERE documents work?
+=head2 Why don't my <<HERE documents work?
 
 Check for these three things:
 
@@ -943,7 +938,8 @@ with
 
     @bad[0]  = `same program that outputs several lines`;
 
-The B<-w> flag will warn you about these matters.
+The C<use warnings> pragma and the B<-w> flag will warn you about these 
+matters.
 
 =head2 How can I remove duplicate elements from a list or array?
 
@@ -1073,7 +1069,7 @@ strings.  Modify if you have other needs.
 
     sub compare_arrays {
        my ($first, $second) = @_;
-       local $^W = 0;  # silence spurious -w undef complaints
+       no warnings;  # silence spurious -w undef complaints
        return 0 unless @$first == @$second;
        for (my $i = 0; $i < @$first; $i++) {
            return 0 if $first->[$i] ne $second->[$i];
@@ -1193,7 +1189,6 @@ Use this:
         my $i;
         for ($i = @$array; --$i; ) {
             my $j = int rand ($i+1);
-            next if $i == $j;
             @$array[$i,$j] = @$array[$j,$i];
         }
     }
@@ -1285,7 +1280,7 @@ Supply a comparison function to sort() (described in L<perlfunc/sort>):
     @list = sort { $a <=> $b } @list;
 
 The default sort function is cmp, string comparison, which would
-sort C<(1, 2, 10)> into C<(1, 10, 2)>.  C<E<lt>=E<gt>>, used above, is
+sort C<(1, 2, 10)> into C<(1, 10, 2)>.  C<< <=> >>, used above, is
 the numerical comparison operator.
 
 If you have a complicated function needed to pull out the part you
@@ -1748,11 +1743,10 @@ if you just want to say, ``Is this a float?''
 
     sub is_numeric { defined getnum($_[0]) } 
 
-Or you could check out
-http://www.perl.com/CPAN/modules/by-module/String/String-Scanf-1.1.tar.gz
-instead.  The POSIX module (part of the standard Perl distribution)
-provides the C<strtol> and C<strtod> for converting strings to double
-and longs, respectively.
+Or you could check out the String::Scanf module on CPAN instead.  The
+POSIX module (part of the standard Perl distribution) provides the
+C<strtod> and C<strtol> for converting strings to double and longs,
+respectively.
 
 =head2 How do I keep persistent data across program calls?