cvs commit: perlfaq perlfaq4.pod

[email protected]
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     02/10/08 01:05:50

  Modified:    .        perlfaq4.pod
  Log:
  * Why doesn't & work the way I want it to?
     + change the result of 11 & 3 to the correct one (3)
  
  * How do I find the current century or millennium?
     + mention POSIX::strftime which is a lot easier to read
     than the other examples.
  
  * How can I make my hash remember the order I put elements into it?
     + made strict clean
  
  Revision  Changes    Path
  1.33      +19 -10    perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -w -r1.32 -r1.33
  --- perlfaq4.pod	10 Sep 2002 19:49:38 -0000	1.32
  +++ perlfaq4.pod	8 Oct 2002 08:05:50 -0000	1.33
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq4 - Data Manipulation ($Revision: 1.32 $, $Date: 2002/09/10 19:49:38 $)
  +perlfaq4 - Data Manipulation ($Revision: 1.33 $, $Date: 2002/10/08 08:05:50 $)
   
   =head1 DESCRIPTION
   
  @@ -263,7 +263,7 @@
   (the number C<3> is treated as the bit pattern C<00000011>).
   
   So, saying C<11 & 3> performs the "and" operation on numbers (yielding
  -C<1>).  Saying C<"11" & "3"> performs the "and" operation on strings
  +C<3>).  Saying C<"11" & "3"> performs the "and" operation on strings
   (yielding C<"1">).
   
   Most problems with C<&> and C<|> arise because the programmer thinks
  @@ -390,11 +390,20 @@
   	return 1+int((((localtime(shift || time))[5] + 1899))/1000);
       } 
   
  -On some systems, you'll find that the POSIX module's strftime() function
  -has been extended in a non-standard way to use a C<%C> format, which they
  -sometimes claim is the "century".  It isn't, because on most such systems,
  -this is only the first two digits of the four-digit year, and thus cannot
  -be used to reliably determine the current century or millennium.
  +You can also use the POSIX strftime() function which may be a bit
  +slower but is easier to read and maintain.
  +
  +	use POSIX qw/strftime/;
  +	
  +	my $week_of_the_year = strftime "%W", localtime;
  +	my $day_of_the_year  = strftime "%j", localtime;
  +
  +On some systems, the POSIX module's strftime() function has
  +been extended in a non-standard way to use a C<%C> format,
  +which they sometimes claim is the "century".  It isn't,
  +because on most such systems, this is only the first two
  +digits of the four-digit year, and thus cannot be used to
  +reliably determine the current century or millennium.
   
   =head2 How can I compare two dates and find the difference?
   
  @@ -1862,11 +1871,11 @@
   Use the Tie::IxHash from CPAN.
   
       use Tie::IxHash;
  -    tie(%myhash, Tie::IxHash);
  -    for ($i=0; $i<20; $i++) {
  +    tie my %myhash, Tie::IxHash;
  +    for (my $i=0; $i<20; $i++) {
           $myhash{$i} = 2*$i;
       }
  -    @keys = keys %myhash;
  +    my @keys = keys %myhash;
       # @keys = (0,1,2,3,...)
   
   =head2 Why does passing a subroutine an undefined element in a hash create it?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.