Skip to content

Commit

Permalink
FAQ sync.
Browse files Browse the repository at this point in the history
p4raw-id: //depot/perl@24128
  • Loading branch information
rgs committed Apr 1, 2005
1 parent 3a89a73 commit 571e049
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
6 changes: 1 addition & 5 deletions pod/perlfaq.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME

perlfaq - frequently asked questions about Perl ($Date: 2005/01/31 15:52:15 $)
perlfaq - frequently asked questions about Perl ($Date: 2005/03/27 07:21:21 $)

=head1 DESCRIPTION

Expand Down Expand Up @@ -317,10 +317,6 @@ How can I use X or Tk with Perl?

=item *

How can I generate simple menus without using CGI or Tk?

=item *

How can I make my Perl program run faster?

=item *
Expand Down
7 changes: 1 addition & 6 deletions pod/perlfaq3.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME

perlfaq3 - Programming Tools ($Revision: 1.46 $, $Date: 2005/02/13 02:36:09 $)
perlfaq3 - Programming Tools ($Revision: 1.47 $, $Date: 2005/03/27 07:21:22 $)

=head1 DESCRIPTION

Expand Down Expand Up @@ -472,11 +472,6 @@ http://www.cpan.org/authors/Stephen_O_Lidie/ , and the
online manpages at
http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html .

=head2 How can I generate simple menus without using CGI or Tk?

The http://www.cpan.org/authors/id/SKUNZ/perlmenu.v4.0.tar.gz
module, which is curses-based, can help with this.

=head2 How can I make my Perl program run faster?

The best way to do this is to come up with a better algorithm. This
Expand Down
5 changes: 3 additions & 2 deletions pod/perlfaq4.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME

perlfaq4 - Data Manipulation ($Revision: 1.60 $, $Date: 2005/02/14 18:24:01 $)
perlfaq4 - Data Manipulation ($Revision: 1.61 $, $Date: 2005/03/11 16:27:53 $)

=head1 DESCRIPTION

Expand Down Expand Up @@ -389,7 +389,7 @@ integers (inclusive), For example: C<random_int_in(50,120)>.

=head2 How do I find the day or week of the year?

The localtime function returns the day of the week. Without an
The localtime function returns the day of the year. Without an
argument localtime uses the current time.

$day_of_year = (localtime)[7];
Expand Down Expand Up @@ -422,6 +422,7 @@ Use the following simple functions:
sub get_century {
return int((((localtime(shift || time))[5] + 1999))/100);
}

sub get_millennium {
return 1+int((((localtime(shift || time))[5] + 1899))/1000);
}
Expand Down
23 changes: 12 additions & 11 deletions pod/perlfaq6.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME

perlfaq6 - Regular Expressions ($Revision: 1.30 $, $Date: 2005/02/14 18:25:48 $)
perlfaq6 - Regular Expressions ($Revision: 1.31 $, $Date: 2005/03/27 07:17:28 $)

=head1 DESCRIPTION

Expand Down Expand Up @@ -630,17 +630,18 @@ These strings do not match /\Bam\B/

=head2 Why does using $&, $`, or $' slow my program down?

Once Perl sees that you need one of these variables anywhere in
the program, it provides them on each and every pattern match.
The same mechanism that handles these provides for the use of $1, $2,
etc., so you pay the same price for each regex that contains capturing
parentheses. If you never use $&, etc., in your script, then regexes
I<without> capturing parentheses won't be penalized. So avoid $&, $',
and $` if you can, but if you can't, once you've used them at all, use
them at will because you've already paid the price. Remember that some
algorithms really appreciate them. As of the 5.005 release. the $&
variable is no longer "expensive" the way the other two are.
(contributed by Anno Siegel)

Once Perl sees that you need one of these variables anywhere in the
program, it provides them on each and every pattern match. That means
that on every pattern match the entire string will be copied, part of
it to $`, part to $&, and part to $'. Thus the penalty is most severe
with long strings and patterns that match often. Avoid $&, $', and $`
if you can, but if you can't, once you've used them at all, use them
at will because you've already paid the price. Remember that some
algorithms really appreciate them. As of the 5.005 release, the $&
variable is no longer "expensive" the way the other two are.

=head2 What good is C<\G> in a regular expression?

You use the C<\G> anchor to start the next match on the same
Expand Down
13 changes: 9 additions & 4 deletions pod/perlfaq7.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME

perlfaq7 - General Perl Language Issues ($Revision: 1.21 $, $Date: 2005/01/21 12:10:22 $)
perlfaq7 - General Perl Language Issues ($Revision: 1.22 $, $Date: 2005/03/27 07:19:01 $)

=head1 DESCRIPTION

Expand Down Expand Up @@ -54,8 +54,8 @@ count as though they were quoted:

This is like this
------------ ---------------
$foo{line} $foo{"line"}
bar => stuff "bar" => stuff
$foo{line} $foo{'line'}
bar => stuff 'bar' => stuff

The final semicolon in a block is optional, as is the final comma in a
list. Good style (see L<perlstyle>) says to put them in except for
Expand Down Expand Up @@ -896,6 +896,8 @@ you probably only want to use hard references.

=head2 What does "bad interpreter" mean?

(contributed by brian d foy)

The "bad interpreter" message comes from the shell, not perl. The
actual message may vary depending on your platform, shell, and locale
settings.
Expand All @@ -905,7 +907,10 @@ line in your perl script (the "shebang" line) does not contain the
right path to perl (or any other program capable of running scripts).
Sometimes this happens when you move the script from one machine to
another and each machine has a different path to perl---/usr/bin/perl
versus /usr/local/bin/perl for instance.
versus /usr/local/bin/perl for instance. It may also indicate
that the source machine has CRLF line terminators and the
destination machine has LF only: the shell tries to find
/usr/bin/perl<CR>, but can't.

If you see "bad interpreter: Permission denied", you need to make your
script executable.
Expand Down

0 comments on commit 571e049

Please sign in to comment.