summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
Diffstat (limited to 'pod')
-rw-r--r--pod/perlfaq4.pod24
-rw-r--r--pod/perlfaq8.pod16
2 files changed, 31 insertions, 9 deletions
diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod
index 27908d5662..aeb7c14c19 100644
--- a/pod/perlfaq4.pod
+++ b/pod/perlfaq4.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq4 - Data Manipulation ($Revision: 1.21 $, $Date: 2002/05/06 13:08:46 $)
+perlfaq4 - Data Manipulation ($Revision: 1.22 $, $Date: 2002/05/16 12:44:24 $)
=head1 DESCRIPTION
@@ -1396,13 +1396,20 @@ Here's another; let's compute spherical volumes:
$_ *= (4/3) * 3.14159; # this will be constant folded
}
-If you want to do the same thing to modify the values of the hash,
-you may not use the C<values> function, oddly enough. You need a slice:
+If you want to do the same thing to modify the values of the
+hash, you can use the C<values> function. As of Perl 5.6
+the values are not copied, so if you modify $orbit (in this
+case), you modify the value.
- for $orbit ( @orbits{keys %orbits} ) {
+ 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>):
@@ -1540,6 +1547,13 @@ get those bits into your @ints array:
This method gets faster the more sparse the bit vector is.
(Courtesy of Tim Bunce and Winfried Koenig.)
+You can make the while loop a lot shorter with this suggestion
+from Benjamin Goldberg:
+
+ while($vec =~ /[^\0]+/g ) {
+ push @ints, grep vec($vec, $_, 1), $-[0] * 8 .. $+[0] * 8;
+ }
+
Or use the CPAN module Bit::Vector:
$vector = Bit::Vector->new($num_of_bits);
diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod
index 2a99a6b2d2..feb10f3947 100644
--- a/pod/perlfaq8.pod
+++ b/pod/perlfaq8.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq8 - System Interaction ($Revision: 1.7 $, $Date: 2002/04/18 14:23:15 $)
+perlfaq8 - System Interaction ($Revision: 1.8 $, $Date: 2002/05/16 12:41:42 $)
=head1 DESCRIPTION
@@ -968,9 +968,17 @@ sysopen():
=head2 How do I install a module from CPAN?
The easiest way is to have a module also named CPAN do it for you.
-This module comes with perl version 5.004 and later. To manually install
-the CPAN module, or any well-behaved CPAN module for that matter, follow
-these steps:
+This module comes with perl version 5.004 and later.
+
+ $ perl -MCPAN -e shell
+
+ cpan shell -- CPAN exploration and modules installation (v1.59_54)
+ ReadLine support enabled
+
+ cpan> install Some::Module
+
+To manually install the CPAN module, or any well-behaved CPAN module
+for that matter, follow these steps:
=over 4