Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pod/buildtoc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ EOH
| perl -ne 'map { -r && print "$_ " } split'`

# Bypass internal shell buffer limit -- can't use case
if perl -e '$a = shift; exit($a =~ m|/|)' $toroff; then
if perl -e '$x = shift; exit($x =~ m|/|)' $toroff; then
echo "$me: empty file list -- did you run install?" >&2
exit 1
fi
Expand Down
30 changes: 15 additions & 15 deletions pod/perlcall.pod
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ and simply returns their sum.

sub Adder
{
my($a, $b) = @_;
$a + $b;
my($x, $y) = @_;
$x + $y;
}

Because we are now concerned with the return value from I<Adder>, the C
Expand Down Expand Up @@ -728,8 +728,8 @@ Here is the Perl subroutine

sub AddSubtract
{
my($a, $b) = @_;
($a+$b, $a-$b);
my($x, $y) = @_;
($x+$y, $x-$y);
}

and this is the C function
Expand Down Expand Up @@ -916,11 +916,11 @@ result, the subroutine calls I<die>.

sub Subtract
{
my ($a, $b) = @_;
my ($x, $y) = @_;

die "death can be fatal\n" if $a < $b;
die "death can be fatal\n" if $x < $y;

$a - $b;
$x - $y;
}

and some C to call it
Expand Down Expand Up @@ -1030,9 +1030,9 @@ version of the call_Subtract example above inside a destructor:
package Foo;
sub new { bless {}, $_[0] }
sub Subtract {
my($a,$b) = @_;
die "death can be fatal" if $a < $b;
$a - $b;
my($x,$y) = @_;
die "death can be fatal" if $x < $y;
$x - $y;
}
sub DESTROY { call_Subtract(5, 4); }
sub foo { die "foo dies"; }
Expand Down Expand Up @@ -1278,8 +1278,8 @@ virtual. The static method, C<PrintID>, prints out simply the class
name and a version number. The virtual method, C<Display>, prints out a
single element of the array. Here is an all-Perl example of using it.

$a = Mine->new('red', 'green', 'blue');
$a->Display(1);
$x = Mine->new('red', 'green', 'blue');
$x->Display(1);
Mine->PrintID;

will print
Expand Down Expand Up @@ -1338,8 +1338,8 @@ the C<PrintID> and C<Display> methods from C.

So the methods C<PrintID> and C<Display> can be invoked like this:

$a = Mine->new('red', 'green', 'blue');
call_Method($a, 'Display', 1);
$x = Mine->new('red', 'green', 'blue');
call_Method($x, 'Display', 1);
call_PrintID('Mine', 'PrintID');

The only thing to note is that, in both the static and virtual methods,
Expand All @@ -1365,7 +1365,7 @@ currently executing.
And here is some Perl to test it.

PrintContext;
$a = PrintContext;
$x = PrintContext;
@a = PrintContext;

The output from that will be
Expand Down
2 changes: 1 addition & 1 deletion pod/perldbmfilter.pod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fix very easily.
$db->filter_store_value( sub { $_ .= "\0" } );

$hash{"abc"} = "def";
my $a = $hash{"ABC"};
my $x = $hash{"ABC"};
# ...
undef $db;
untie %hash;
Expand Down
64 changes: 32 additions & 32 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ coerced to a scalar - the number of elements in the array.
(F) Each subroutine signature parameter declaration must start with a valid
sigil; for example:

sub foo ($a, $, $b = 1, @c) {}
sub foo ($x, $, $y = 1, @z) {}

=item A slurpy parameter may not have a default value

(F) Only scalar subroutine signature parameters may have a default value;
for example:

sub foo ($a = 1) {} # legal
sub foo (@a = (1)) {} # invalid
sub foo (%a = (a => b)) {} # invalid
sub foo ($x = 1) {} # legal
sub foo (@x = (1)) {} # invalid
sub foo (%x = (a => b)) {} # invalid

=item assertion botched: %s

Expand Down Expand Up @@ -2890,7 +2890,7 @@ For example:

use feature 'signatures;
sub foo ($$) {} # illegal - was expecting a signature
sub foo ($a, $b)
sub foo ($x, $y)
:prototype($$) {} # legal


Expand Down Expand Up @@ -2938,9 +2938,9 @@ other than C<=> introducing a default, C<,> or C<)>.

use feature 'signatures';
sub foo ($=1) {} # legal
sub foo ($a = 1) {} # legal
sub foo ($a += 1) {} # illegal
sub foo ($a == 1) {} # illegal
sub foo ($x = 1) {} # legal
sub foo ($x += 1) {} # illegal
sub foo ($x == 1) {} # illegal

=item Illegal pattern in regex; marked by S<<-- HERE> in m/%s/

Expand Down Expand Up @@ -3064,8 +3064,8 @@ throwing an exception.
=item Initialization of state variables in list currently forbidden

(F) C<state> only permits initializing a single variable, specified
without parentheses. So C<state $a = 42> and C<state @a = qw(a b c)> are
allowed, but not C<state ($a) = 42> or C<(state $a) = 42>. To initialize
without parentheses. So C<state $x = 42> and C<state @x = qw(a b c)> are
allowed, but not C<state ($x) = 42> or C<(state $x) = 42>. To initialize
more than one C<state> variable, initialize them one at a time.

=item %%s[%s] in scalar context better written as $%s[%s]
Expand Down Expand Up @@ -3830,8 +3830,8 @@ doing it Perl met a malformed Unicode surrogate.

=item Mandatory parameter follows optional parameter

(F) In a subroutine signature, you wrote something like "$a = undef,
$b", making an earlier parameter optional and a later one mandatory.
(F) In a subroutine signature, you wrote something like "$x = undef,
$y", making an earlier parameter optional and a later one mandatory.
Parameters are filled from left to right, so it's impossible for the
caller to omit an earlier one and pass a later one. If you want to act
as if the parameters are filled from right to left, declare the rightmost
Expand Down Expand Up @@ -4162,8 +4162,8 @@ They're written like C<$foo[1][2][3]>, as in C.
the last parameter, and there must not be more than one of them; for
example:

sub foo ($a, @b) {} # legal
sub foo ($a, @b, %) {} # invalid
sub foo ($x, @y) {} # legal
sub foo ($x, @y, %) {} # invalid

=item '/' must follow a numeric type in unpack

Expand Down Expand Up @@ -4568,10 +4568,10 @@ particular to avoid confusion with the C<$#> variable. For example:

# bad
sub f ($# ignore first arg
, $b) {}
, $y) {}
# good
sub f ($, # ignore first arg
$b) {}
$y) {}

=item Not an ARRAY reference

Expand Down Expand Up @@ -4811,10 +4811,10 @@ example, if you say "*foo *foo" it will be interpreted as if you said

=item Optional parameter lacks default expression

(F) In a subroutine signature, you wrote something like "$a =", making a
(F) In a subroutine signature, you wrote something like "$x =", making a
named optional parameter without a default value. A nameless optional
parameter is permitted to have no default value, but a named one must
have a specific default. You probably want "$a = undef".
have a specific default. You probably want "$x = undef".

=item "our" variable %s redeclared

Expand Down Expand Up @@ -5370,15 +5370,15 @@ Perl assumes that memory is now corrupted. See L<perlfunc/ioctl>.
flow operator (e.g. C<return>) and a low-precedence operator like
C<or>. Consider:

sub { return $a or $b; }
sub { return $x or $y; }

This is parsed as:

sub { (return $a) or $b; }
sub { (return $x) or $y; }

Which is effectively just:

sub { return $a; }
sub { return $x; }

Either use parentheses or the high-precedence variant of the operator.

Expand Down Expand Up @@ -6190,8 +6190,8 @@ C<can> may break this.
come before the signature. Note that this order was the opposite in
versions 5.22..5.26. So:

sub foo :lvalue ($a, $b) { ... } # 5.20 and 5.28 +
sub foo ($a, $b) :lvalue { ... } # 5.22 .. 5.26
sub foo :lvalue ($x, $y) { ... } # 5.20 and 5.28 +
sub foo ($x, $y) :lvalue { ... } # 5.22 .. 5.26

=item Subroutine "&%s" is not available

Expand Down Expand Up @@ -7105,12 +7105,12 @@ flags for the regex. One of the ones you specified is invalid. One way
this can happen is if you didn't put in white space between the end of
the regex and a following alphanumeric operator:

if ($a =~ /foo/and $bar == 3) { ... }
if ($x =~ /foo/and $bar == 3) { ... }

The C<"a"> is a valid modifier flag, but the C<"n"> is not, and raises
this error. Likely what was meant instead was:

if ($a =~ /foo/ and $bar == 3) { ... }
if ($x =~ /foo/ and $bar == 3) { ... }

=item Unknown "re" subpragma '%s' (known ones are: %s)

Expand Down Expand Up @@ -7881,26 +7881,26 @@ declared in an outer anonymous subroutine that has not yet been created.
(Remember that named subs are created at compile time, while anonymous
subs are created at run-time.) For example,

sub { my $a; sub f { $a } }
sub { my $x; sub f { $x } }

At the time that f is created, it can't capture the current value of $a,
At the time that f is created, it can't capture the current value of $x,
since the anonymous subroutine hasn't been created yet. Conversely,
the following won't give a warning since the anonymous subroutine has by
now been created and is live:

sub { my $a; eval 'sub f { $a }' }->();
sub { my $x; eval 'sub f { $x }' }->();

The second situation is caused by an eval accessing a variable that has
gone out of scope, for example,

sub f {
my $a;
sub { eval '$a' }
my $x;
sub { eval '$x' }
}
f()->();

Here, when the '$a' in the eval is being compiled, f() is not currently
being executed, so its $a is not available for capture.
Here, when the '$x' in the eval is being compiled, f() is not currently
being executed, so its $x is not available for capture.

=item Variable "%s" is not imported%s

Expand Down
2 changes: 1 addition & 1 deletion pod/perldsc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ That's because Perl doesn't (ever) implicitly dereference your variables.
If you want to get at the thing a reference is referring to, then you have
to do this yourself using either prefix typing indicators, like
C<${$blah}>, C<@{$blah}>, C<@{$blah[$i]}>, or else postfix pointer arrows,
like C<$a-E<gt>[3]>, C<$h-E<gt>{fred}>, or even C<$ob-E<gt>method()-E<gt>[3]>.
like C<< $arr->[3] >>, C<< $hash->{fred} >>, or even C<< $obj->method()->[3] >>.

=head1 COMMON MISTAKES

Expand Down
12 changes: 6 additions & 6 deletions pod/perlebcdic.pod
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,19 @@ be compiled to run on.

my %ebcdic = ( 176 => 'cp37', 95 => 'cp1047', 106 => 'posix-bc' );

# $a is in EBCDIC code points
from_to($a, $ebcdic{ord '^'}, 'latin1');
# $a is ISO 8859-1 code points
# $x is in EBCDIC code points
from_to($x, $ebcdic{ord '^'}, 'latin1');
# $x is ISO 8859-1 code points

and from Latin-1 code points to EBCDIC code points

use Encode 'from_to';

my %ebcdic = ( 176 => 'cp37', 95 => 'cp1047', 106 => 'posix-bc' );

# $a is ISO 8859-1 code points
from_to($a, 'latin1', $ebcdic{ord '^'});
# $a is in EBCDIC code points
# $x is ISO 8859-1 code points
from_to($x, 'latin1', $ebcdic{ord '^'});
# $x is in EBCDIC code points

For doing I/O it is suggested that you use the autotranslating features
of PerlIO, see L<perluniintro>.
Expand Down
22 changes: 11 additions & 11 deletions pod/perlembed.pod
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,18 @@ the first, a C<float> from the second, and a C<char *> from the third.
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);

/** Treat $a as an integer **/
eval_pv("$a = 3; $a **= 2", TRUE);
printf("a = %d\n", SvIV(get_sv("a", 0)));
/** Treat $x as an integer **/
eval_pv("$x = 3; $x **= 2", TRUE);
printf("x = %d\n", SvIV(get_sv("x", 0)));

/** Treat $a as a float **/
eval_pv("$a = 3.14; $a **= 2", TRUE);
printf("a = %f\n", SvNV(get_sv("a", 0)));
/** Treat $x as a float **/
eval_pv("$x = 3.14; $x **= 2", TRUE);
printf("x = %f\n", SvNV(get_sv("x", 0)));

/** Treat $a as a string **/
/** Treat $x as a string **/
eval_pv(
"$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
printf("a = %s\n", SvPV_nolen(get_sv("a", 0)));
"$x = 'rekcaH lreP rehtonA tsuJ'; $x = reverse($x);", TRUE);
printf("x = %s\n", SvPV_nolen(get_sv("x", 0)));

perl_destruct(my_perl);
perl_free(my_perl);
Expand Down Expand Up @@ -614,8 +614,8 @@ sounds, because Perl implements ** with C's I<pow()> function). First
I'll create a stub exponentiation function in I<power.pl>:

sub expo {
my ($a, $b) = @_;
return $a ** $b;
my ($x, $y) = @_;
return $x ** $y;
}

Now I'll create a C program, I<power.c>, with a function
Expand Down
Loading