Update the Mac OS X situation.
[p5sagit/p5-mst-13.2.git] / pod / perlfaq4.pod
index b530516..27908d5 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq4 - Data Manipulation ($Revision: 1.19 $, $Date: 2002/03/11 22:15:19 $)
+perlfaq4 - Data Manipulation ($Revision: 1.21 $, $Date: 2002/05/06 13:08:46 $)
 
 =head1 DESCRIPTION
 
@@ -135,7 +135,7 @@ functions is that it works with numbers of ANY size, that it is
 optimized for speed on some operations, and for at least some
 programmers the notation might be familiar.
 
-=item B<How do I convert Hexadecimal into decimal:>
+=item B<How do I convert hexadecimal into decimal:>
 
 Using perl's built in conversion of 0x notation:
 
@@ -214,6 +214,11 @@ Using Bit::Vector
 
 =item B<How do I convert from binary to decimal:>
 
+Perl 5.6 lets you write binary numbers directly with
+the 0b notation:
+
+       $number = 0b10110110;
+
 Using pack and ord
 
     $decimal = ord(pack('B8', '10110110'));
@@ -1335,28 +1340,21 @@ lists, or you could just do something like this with an array:
 If you either have Perl 5.8.0 or later installed, or if you have
 Scalar-List-Utils 1.03 or later installed, you can say:
 
-        use List::Util 'shuffle';
+    use List::Util 'shuffle';
 
        @shuffled = shuffle(@list);
 
-If not, you can use this:
+If not, you can use a Fisher-Yates shuffle.
 
-    # fisher_yates_shuffle
-    # generate a random permutation of an array in place
-    # As in shuffling a deck of cards
-    #
     sub fisher_yates_shuffle {
         my $deck = shift;  # $deck is a reference to an array
         my $i = @$deck;
-        while (--$i) {
+        while ($i--) {
             my $j = int rand ($i+1);
             @$deck[$i,$j] = @$deck[$j,$i];
         }
     }
 
-And here is an example of using it:
-
-    #
     # shuffle my mpeg collection
     #
     my @mpeg = <audio/*/*.mp3>;