diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-29 01:16:23 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-29 01:16:23 +0000 |
commit | 818c4caa84c1eb56340765ecb8e5b3df206aeab1 (patch) | |
tree | f47399cf80a385fc6ad627beb9a11c0ebf3c1763 /pod/perlfaq4.pod | |
parent | 23be5fc44878216e0d4fdb73cb32d7e0832e94bc (diff) | |
download | perl-818c4caa84c1eb56340765ecb8e5b3df206aeab1.tar.gz |
pod cleanups.
p4raw-id: //depot/perl@16849
Diffstat (limited to 'pod/perlfaq4.pod')
-rw-r--r-- | pod/perlfaq4.pod | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index ab71cb19e0..365bdbd4f9 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -135,7 +135,9 @@ 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:> +=over 4 + +=item How do I convert hexadecimal into decimal Using perl's built in conversion of 0x notation: @@ -158,7 +160,7 @@ Using the CPAN module Bit::Vector: $vec = Bit::Vector->new_Hex(32, "DEADBEEF"); $dec = $vec->to_Dec(); -=item B<How do I convert from decimal to hexadecimal:> +=item How do I convert from decimal to hexadecimal Using sprint: @@ -181,7 +183,7 @@ And Bit::Vector supports odd bit counts: $vec->Resize(32); # suppress leading 0 if unwanted $hex = $vec->to_Hex(); -=item B<How do I convert from octal to decimal:> +=item How do I convert from octal to decimal Using Perl's built in conversion of numbers with leading zeros: @@ -200,7 +202,7 @@ Using Bit::Vector: $vec->Chunk_List_Store(3, split(//, reverse "33653337357")); $dec = $vec->to_Dec(); -=item B<How do I convert from decimal to octal:> +=item How do I convert from decimal to octal Using sprintf: @@ -212,7 +214,7 @@ Using Bit::Vector $vec = Bit::Vector->new_Dec(32, -559038737); $oct = reverse join('', $vec->Chunk_List_Read(3)); -=item B<How do I convert from binary to decimal:> +=item How do I convert from binary to decimal Perl 5.6 lets you write binary numbers directly with the 0b notation: @@ -236,7 +238,7 @@ Using Bit::Vector: $vec = Bit::Vector->new_Bin(32, "11011110101011011011111011101111"); $dec = $vec->to_Dec(); -=item B<How do I convert from decimal to binary:> +=item How do I convert from decimal to binary Using unpack; @@ -251,6 +253,7 @@ Using Bit::Vector: The remaining transformations (e.g. hex -> oct, bin -> hex, etc.) are left as an exercise to the inclined reader. +=back =head2 Why doesn't & work the way I want it to? @@ -1404,12 +1407,12 @@ case), you modify the value. for $orbit ( values %orbits ) { ($orbit **= 3) *= (4/3) * 3.14159; } - + Prior to perl 5.6 C<values> returned copies of the values, so older perl code often contains constructions such as C<@orbits{keys %orbits}> instead of C<values %orbits> where the hash is to be modified. - + =head2 How do I select a random element from an array? Use the rand() function (see L<perlfunc/rand>): |