summaryrefslogtreecommitdiff
path: root/pod/perlfaq7.pod
diff options
context:
space:
mode:
authorTom Christiansen <tchrist@perl.com>1999-01-07 16:05:02 -0700
committerJarkko Hietaniemi <jhi@iki.fi>1999-01-08 11:51:52 +0000
commit65acb1b1d672587d3a0d073613a475584830e38e (patch)
treefcb09719fada1c9453493712a798b889dd89b086 /pod/perlfaq7.pod
parentae83f3772b2dd371e676035c6714025e89d7e08f (diff)
downloadperl-65acb1b1d672587d3a0d073613a475584830e38e.tar.gz
FAQ jumbo patch from tchrist.
Message-Id: <199901080605.XAA20229@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20231@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq1.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20233@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq2.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20235@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq3.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20237@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq4.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20239@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq5.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20241@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq6.pod Date: Thu, 7 Jan 1999 23:05:02 -0700 Message-Id: <199901080605.XAA20243@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq7.pod Date: Thu, 7 Jan 1999 23:05:03 -0700 Message-Id: <199901080605.XAA20245@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq8.pod Date: Thu, 7 Jan 1999 23:05:03 -0700 Message-Id: <199901080605.XAA20257@jhereg.perl.com> From: Tom Christiansen <tchrist@jhereg.perl.com> To: pumpkings@jhereg.perl.com Subject: newest version of perlfaq9.pod Date: Thu, 7 Jan 1999 23:05:03 -0700 p4raw-id: //depot/cfgperl@2588
Diffstat (limited to 'pod/perlfaq7.pod')
-rw-r--r--pod/perlfaq7.pod44
1 files changed, 37 insertions, 7 deletions
diff --git a/pod/perlfaq7.pod b/pod/perlfaq7.pod
index 07a6570185..5794bfe372 100644
--- a/pod/perlfaq7.pod
+++ b/pod/perlfaq7.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq7 - Perl Language Issues ($Revision: 1.21 $, $Date: 1998/06/22 15:20:07 $)
+perlfaq7 - Perl Language Issues ($Revision: 1.24 $, $Date: 1999/01/08 05:32:11 $)
=head1 DESCRIPTION
@@ -180,7 +180,7 @@ own module. Make sure to change the names appropriately.
# if using RCS/CVS, this next line may be preferred,
# but beware two-digit versions.
- $VERSION = do{my@r=q$Revision: 1.21 $=~/\d+/g;sprintf '%d.'.'%02d'x$#r,@r};
+ $VERSION = do{my@r=q$Revision: 1.24 $=~/\d+/g;sprintf '%d.'.'%02d'x$#r,@r};
@ISA = qw(Exporter);
@EXPORT = qw(&func1 &func2 &func3);
@@ -229,6 +229,10 @@ own module. Make sure to change the names appropriately.
1; # modules must return true
+The h2xs program will create stubs for all the important stuff for you:
+
+ % h2xs -XA -n My::Module
+
=head2 How do I create a class?
See L<perltoot> for an introduction to classes and objects, as well as
@@ -344,7 +348,7 @@ reference to an existing or anonymous variable or function:
func( \$some_scalar );
- func( \$some_array );
+ func( \@some_array );
func( [ 1 .. 10 ] );
func( \%some_hash );
@@ -392,7 +396,7 @@ If you're planning on generating new filehandles, you could do this:
To pass regexps around, you'll need to either use one of the highly
experimental regular expression modules from CPAN (Nick Ing-Simmons's
Regexp or Ilya Zakharevich's Devel::Regexp), pass around strings
-and use an exception-trapping eval, or else be be very, very clever.
+and use an exception-trapping eval, or else be very, very clever.
Here's an example of how to pass in a string to be regexp compared:
sub compare($$) {
@@ -563,7 +567,7 @@ However, dynamic variables (aka global, local, or package variables)
are effectively shallowly bound. Consider this just one more reason
not to use them. See the answer to L<"What's a closure?">.
-=head2 Why doesn't "my($foo) = <FILE>;" work right?
+=head2 Why doesn't "my($foo) = E<lt>FILEE<gt>;" work right?
C<my()> and C<local()> give list context to the right hand side
of C<=>. The E<lt>FHE<gt> read operation, like so many of Perl's
@@ -594,7 +598,7 @@ Why do you want to do that? :-)
If you want to override a predefined function, such as open(),
then you'll have to import the new definition from a different
module. See L<perlsub/"Overriding Builtin Functions">. There's
-also an example in L<perltoot/"Class::Struct">.
+also an example in L<perltoot/"Class::Template">.
If you want to overload a Perl operator, such as C<+> or C<**>,
then you'll want to use the C<use overload> pragma, documented
@@ -797,9 +801,34 @@ This can't go just anywhere. You have to put a pod directive where
the parser is expecting a new statement, not just in the middle
of an expression or some other arbitrary yacc grammar production.
+=head2 How do I clear a package?
+
+Use this code, provided by Mark-Jason Dominus:
+
+ sub scrub_package {
+ no strict 'refs';
+ my $pack = shift;
+ die "Shouldn't delete main package"
+ if $pack eq "" || $pack eq "main";
+ my $stash = *{$pack . '::'}{HASH};
+ my $name;
+ foreach $name (keys %$stash) {
+ my $fullname = $pack . '::' . $name;
+ # Get rid of everything with that name.
+ undef $$fullname;
+ undef @$fullname;
+ undef %$fullname;
+ undef &$fullname;
+ undef *$fullname;
+ }
+ }
+
+Or, if you're using a recent release of Perl, you can
+just use the Symbol::delete_package() function instead.
+
=head1 AUTHOR AND COPYRIGHT
-Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+Copyright (c) 1997-1999 Tom Christiansen and Nathan Torkington.
All rights reserved.
When included as part of the Standard Version of Perl, or as part of
@@ -814,3 +843,4 @@ are hereby placed into the public domain. You are permitted and
encouraged to use this code in your own programs for fun
or for profit as you see fit. A simple comment in the code giving
credit would be courteous but is not required.
+