summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Schubiger <schubiger@cpan.org>2005-10-31 23:48:27 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-11-10 10:52:51 +0000
commit4358a253560c226dd674c77f83b913c071c4fa25 (patch)
treed5881aefffcd9b943217161889e849dfb97df0ec
parent42d1cefd9a529012253aff0d502edf7a4f6a6ac3 (diff)
downloadperl-4358a253560c226dd674c77f83b913c071c4fa25.tar.gz
remove whitespace preceding semicolon in docs
Message-ID: <20051031214827.GH24416@accognoscere.homeunix.org> p4raw-id: //depot/perl@26073
-rw-r--r--pod/perl561delta.pod4
-rw-r--r--pod/perl56delta.pod4
-rw-r--r--pod/perlcall.pod536
-rw-r--r--pod/perldbmfilter.pod68
-rw-r--r--pod/perldiag.pod2
-rw-r--r--pod/perlfaq5.pod2
-rw-r--r--pod/perlfilter.pod128
-rw-r--r--pod/perlipc.pod4
-rw-r--r--pod/perllexwarn.pod116
-rw-r--r--pod/perlop.pod4
-rw-r--r--pod/perlre.pod16
-rw-r--r--pod/perlsub.pod14
-rw-r--r--pod/perltrap.pod16
-rw-r--r--pod/perlxs.pod4
14 files changed, 459 insertions, 459 deletions
diff --git a/pod/perl561delta.pod b/pod/perl561delta.pod
index ef4caa7a72..ab6067ca20 100644
--- a/pod/perl561delta.pod
+++ b/pod/perl561delta.pod
@@ -763,13 +763,13 @@ as requiring an automatic lock() when it is entered, you had to declare
that with a C<use attrs> pragma in the body of the subroutine.
That can now be accomplished with declaration syntax, like this:
- sub mymethod : locked method ;
+ sub mymethod : locked method;
...
sub mymethod : locked method {
...
}
- sub othermethod :locked :method ;
+ sub othermethod :locked :method;
...
sub othermethod :locked :method {
...
diff --git a/pod/perl56delta.pod b/pod/perl56delta.pod
index b5425b2486..89d62371d8 100644
--- a/pod/perl56delta.pod
+++ b/pod/perl56delta.pod
@@ -165,13 +165,13 @@ as requiring an automatic lock() when it is entered, you had to declare
that with a C<use attrs> pragma in the body of the subroutine.
That can now be accomplished with declaration syntax, like this:
- sub mymethod : locked method ;
+ sub mymethod : locked method;
...
sub mymethod : locked method {
...
}
- sub othermethod :locked :method ;
+ sub othermethod :locked :method;
...
sub othermethod :locked :method {
...
diff --git a/pod/perlcall.pod b/pod/perlcall.pod
index 7878ef9e9d..1a9ac8ddad 100644
--- a/pod/perlcall.pod
+++ b/pod/perlcall.pod
@@ -53,10 +53,10 @@ be aware of a few important definitions.
Perl has a number of C functions that allow you to call Perl
subroutines. They are
- I32 call_sv(SV* sv, I32 flags) ;
- I32 call_pv(char *subname, I32 flags) ;
- I32 call_method(char *methname, I32 flags) ;
- I32 call_argv(char *subname, I32 flags, register char **argv) ;
+ I32 call_sv(SV* sv, I32 flags);
+ I32 call_pv(char *subname, I32 flags);
+ I32 call_method(char *methname, I32 flags);
+ I32 call_argv(char *subname, I32 flags, register char **argv);
The key function is I<call_sv>. All the other functions are
fairly simple wrappers which make it easier to call Perl subroutines in
@@ -265,7 +265,7 @@ illustrates this
sub joe
{ &fred }
- &joe(1,2,3) ;
+ &joe(1,2,3);
This will print
@@ -389,7 +389,7 @@ print out the UID of the process.
sub PrintUID
{
- print "UID is $<\n" ;
+ print "UID is $<\n";
}
and here is a C function to call it
@@ -397,10 +397,10 @@ and here is a C function to call it
static void
call_PrintUID()
{
- dSP ;
+ dSP;
- PUSHMARK(SP) ;
- call_pv("PrintUID", G_DISCARD|G_NOARGS) ;
+ PUSHMARK(SP);
+ call_pv("PrintUID", G_DISCARD|G_NOARGS);
}
Simple, eh.
@@ -450,31 +450,31 @@ So the Perl subroutine would look like this
sub LeftString
{
- my($s, $n) = @_ ;
- print substr($s, 0, $n), "\n" ;
+ my($s, $n) = @_;
+ print substr($s, 0, $n), "\n";
}
The C function required to call I<LeftString> would look like this.
static void
call_LeftString(a, b)
- char * a ;
- int b ;
+ char * a;
+ int b;
{
- dSP ;
+ dSP;
- ENTER ;
- SAVETMPS ;
+ ENTER;
+ SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpv(a, 0)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
call_pv("LeftString", G_DISCARD);
- FREETMPS ;
- LEAVE ;
+ FREETMPS;
+ LEAVE;
}
Here are a few notes on the C function I<call_LeftString>.
@@ -540,13 +540,13 @@ we will have to tidy up the Perl stack and dispose of mortal SVs.
This is the purpose of
- ENTER ;
- SAVETMPS ;
+ ENTER;
+ SAVETMPS;
at the start of the function, and
- FREETMPS ;
- LEAVE ;
+ FREETMPS;
+ LEAVE;
at the end. The C<ENTER>/C<SAVETMPS> pair creates a boundary for any
temporaries we create. This means that the temporaries we get rid of
@@ -582,8 +582,8 @@ and simply returns their sum.
sub Adder
{
- my($a, $b) = @_ ;
- $a + $b ;
+ my($a, $b) = @_;
+ $a + $b;
}
Because we are now concerned with the return value from I<Adder>, the C
@@ -591,32 +591,32 @@ function required to call it is now a bit more complex.
static void
call_Adder(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- int count ;
+ dSP;
+ int count;
- ENTER ;
+ ENTER;
SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
count = call_pv("Adder", G_SCALAR);
- SPAGAIN ;
+ SPAGAIN;
if (count != 1)
- croak("Big trouble\n") ;
+ croak("Big trouble\n");
- printf ("The sum of %d and %d is %d\n", a, b, POPi) ;
+ printf ("The sum of %d and %d is %d\n", a, b, POPi);
- PUTBACK ;
- FREETMPS ;
- LEAVE ;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
}
Points to note this time are
@@ -687,46 +687,46 @@ Here is the Perl subroutine
sub AddSubtract
{
- my($a, $b) = @_ ;
- ($a+$b, $a-$b) ;
+ my($a, $b) = @_;
+ ($a+$b, $a-$b);
}
and this is the C function
static void
call_AddSubtract(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- int count ;
+ dSP;
+ int count;
- ENTER ;
+ ENTER;
SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
count = call_pv("AddSubtract", G_ARRAY);
- SPAGAIN ;
+ SPAGAIN;
if (count != 2)
- croak("Big trouble\n") ;
+ croak("Big trouble\n");
- printf ("%d - %d = %d\n", a, b, POPi) ;
- printf ("%d + %d = %d\n", a, b, POPi) ;
+ printf ("%d - %d = %d\n", a, b, POPi);
+ printf ("%d + %d = %d\n", a, b, POPi);
- PUTBACK ;
- FREETMPS ;
- LEAVE ;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
}
If I<call_AddSubtract> is called like this
- call_AddSubtract(7, 4) ;
+ call_AddSubtract(7, 4);
then here is the output
@@ -757,33 +757,33 @@ context, like this
static void
call_AddSubScalar(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- int count ;
- int i ;
+ dSP;
+ int count;
+ int i;
- ENTER ;
+ ENTER;
SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
count = call_pv("AddSubtract", G_SCALAR);
- SPAGAIN ;
+ SPAGAIN;
- printf ("Items Returned = %d\n", count) ;
+ printf ("Items Returned = %d\n", count);
- for (i = 1 ; i <= count ; ++i)
- printf ("Value %d = %d\n", i, POPi) ;
+ for (i = 1; i <= count; ++i)
+ printf ("Value %d = %d\n", i, POPi);
- PUTBACK ;
- FREETMPS ;
- LEAVE ;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
}
The other modification made is that I<call_AddSubScalar> will print the
@@ -791,7 +791,7 @@ number of items returned from the Perl subroutine and their value (for
simplicity it assumes that they are integer). So if
I<call_AddSubScalar> is called
- call_AddSubScalar(7, 4) ;
+ call_AddSubScalar(7, 4);
then the output will be
@@ -813,44 +813,44 @@ each directly.
sub Inc
{
- ++ $_[0] ;
- ++ $_[1] ;
+ ++ $_[0];
+ ++ $_[1];
}
and here is a C function to call it.
static void
call_Inc(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- int count ;
- SV * sva ;
- SV * svb ;
+ dSP;
+ int count;
+ SV * sva;
+ SV * svb;
- ENTER ;
+ ENTER;
SAVETMPS;
- sva = sv_2mortal(newSViv(a)) ;
- svb = sv_2mortal(newSViv(b)) ;
+ sva = sv_2mortal(newSViv(a));
+ svb = sv_2mortal(newSViv(b));
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sva);
XPUSHs(svb);
- PUTBACK ;
+ PUTBACK;
count = call_pv("Inc", G_DISCARD);
if (count != 0)
croak ("call_Inc: expected 0 values from 'Inc', got %d\n",
- count) ;
+ count);
- printf ("%d + 1 = %d\n", a, SvIV(sva)) ;
- printf ("%d + 1 = %d\n", b, SvIV(svb)) ;
+ printf ("%d + 1 = %d\n", a, SvIV(sva));
+ printf ("%d + 1 = %d\n", b, SvIV(svb));
- FREETMPS ;
- LEAVE ;
+ FREETMPS;
+ LEAVE;
}
To be able to access the two parameters that were pushed onto the stack
@@ -872,54 +872,54 @@ result, the subroutine calls I<die>.
sub Subtract
{
- my ($a, $b) = @_ ;
+ my ($a, $b) = @_;
- die "death can be fatal\n" if $a < $b ;
+ die "death can be fatal\n" if $a < $b;
- $a - $b ;
+ $a - $b;
}
and some C to call it
static void
call_Subtract(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- int count ;
+ dSP;
+ int count;
- ENTER ;
+ ENTER;
SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
count = call_pv("Subtract", G_EVAL|G_SCALAR);
- SPAGAIN ;
+ SPAGAIN;
/* Check the eval first */
if (SvTRUE(ERRSV))
{
STRLEN n_a;
- printf ("Uh oh - %s\n", SvPV(ERRSV, n_a)) ;
- POPs ;
+ printf ("Uh oh - %s\n", SvPV(ERRSV, n_a));
+ POPs;
}
else
{
if (count != 1)
croak("call_Subtract: wanted 1 value from 'Subtract', got %d\n",
- count) ;
+ count);
- printf ("%d - %d = %d\n", a, b, POPi) ;
+ printf ("%d - %d = %d\n", a, b, POPi);
}
- PUTBACK ;
- FREETMPS ;
- LEAVE ;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
}
If I<call_Subtract> is called thus
@@ -948,13 +948,13 @@ The code
if (SvTRUE(ERRSV))
{
STRLEN n_a;
- printf ("Uh oh - %s\n", SvPV(ERRSV, n_a)) ;
- POPs ;
+ printf ("Uh oh - %s\n", SvPV(ERRSV, n_a));
+ POPs;
}
is the direct equivalent of this bit of Perl
- print "Uh oh - $@\n" if $@ ;
+ print "Uh oh - $@\n" if $@;
C<PL_errgv> is a perl global of type C<GV *> that points to the
symbol table entry containing the error. C<ERRSV> therefore
@@ -981,7 +981,7 @@ version of the call_Subtract example above inside a destructor:
sub new { bless {}, $_[0] }
sub Subtract {
my($a,$b) = @_;
- die "death can be fatal" if $a < $b ;
+ die "death can be fatal" if $a < $b;
$a - $b;
}
sub DESTROY { call_Subtract(5, 4); }
@@ -1016,10 +1016,10 @@ Consider the Perl code below
sub fred
{
- print "Hello there\n" ;
+ print "Hello there\n";
}
- CallSubPV("fred") ;
+ CallSubPV("fred");
Here is a snippet of XSUB which defines I<CallSubPV>.
@@ -1027,8 +1027,8 @@ Here is a snippet of XSUB which defines I<CallSubPV>.
CallSubPV(name)
char * name
CODE:
- PUSHMARK(SP) ;
- call_pv(name, G_DISCARD|G_NOARGS) ;
+ PUSHMARK(SP);
+ call_pv(name, G_DISCARD|G_NOARGS);
That is fine as far as it goes. The thing is, the Perl subroutine
can be specified as only a string. For Perl 4 this was adequate,
@@ -1043,16 +1043,16 @@ I<call_sv> instead of I<call_pv>.
CallSubSV(name)
SV * name
CODE:
- PUSHMARK(SP) ;
- call_sv(name, G_DISCARD|G_NOARGS) ;
+ PUSHMARK(SP);
+ call_sv(name, G_DISCARD|G_NOARGS);
Because we are using an SV to call I<fred> the following can all be used
- CallSubSV("fred") ;
- CallSubSV(\&fred) ;
- $ref = \&fred ;
- CallSubSV($ref) ;
- CallSubSV( sub { print "Hello there\n" } ) ;
+ CallSubSV("fred");
+ CallSubSV(\&fred);
+ $ref = \&fred;
+ CallSubSV($ref);
+ CallSubSV( sub { print "Hello there\n" } );
As you can see, I<call_sv> gives you much greater flexibility in
how you can specify the Perl subroutine.
@@ -1062,30 +1062,30 @@ example above) which corresponds to the Perl subroutine so that it can
be used later in the program, it not enough just to store a copy of the
pointer to the SV. Say the code above had been like this
- static SV * rememberSub ;
+ static SV * rememberSub;
void
SaveSub1(name)
SV * name
CODE:
- rememberSub = name ;
+ rememberSub = name;
void
CallSavedSub1()
CODE:
- PUSHMARK(SP) ;
- call_sv(rememberSub, G_DISCARD|G_NOARGS) ;
+ PUSHMARK(SP);
+ call_sv(rememberSub, G_DISCARD|G_NOARGS);
The reason this is wrong is that by the time you come to use the
pointer C<rememberSub> in C<CallSavedSub1>, it may or may not still refer
to the Perl subroutine that was recorded in C<SaveSub1>. This is
particularly true for these cases
- SaveSub1(\&fred) ;
- CallSavedSub1() ;
+ SaveSub1(\&fred);
+ CallSavedSub1();
- SaveSub1( sub { print "Hello there\n" } ) ;
- CallSavedSub1() ;
+ SaveSub1( sub { print "Hello there\n" } );
+ CallSavedSub1();
By the time each of the C<SaveSub1> statements above have been executed,
the SV*s which corresponded to the parameters will no longer exist.
@@ -1097,10 +1097,10 @@ for each of the C<CallSavedSub1> lines.
Similarly, with this code
- $ref = \&fred ;
- SaveSub1($ref) ;
- $ref = 47 ;
- CallSavedSub1() ;
+ $ref = \&fred;
+ SaveSub1($ref);
+ $ref = 47;
+ CallSavedSub1();
you can expect one of these messages (which you actually get is dependent on
the version of Perl you are using)
@@ -1120,10 +1120,10 @@ loudly.
A similar but more subtle problem is illustrated with this code
- $ref = \&fred ;
- SaveSub1($ref) ;
- $ref = \&joe ;
- CallSavedSub1() ;
+ $ref = \&fred;
+ SaveSub1($ref);
+ $ref = \&joe;
+ CallSavedSub1();
This time whenever C<CallSavedSub1> get called it will execute the Perl
subroutine C<joe> (assuming it exists) rather than C<fred> as was
@@ -1132,7 +1132,7 @@ originally requested in the call to C<SaveSub1>.
To get around these problems it is necessary to take a full copy of the
SV. The code below shows C<SaveSub2> modified to do that
- static SV * keepSub = (SV*)NULL ;
+ static SV * keepSub = (SV*)NULL;
void
SaveSub2(name)
@@ -1141,16 +1141,16 @@ SV. The code below shows C<SaveSub2> modified to do that
/* Take a copy of the callback */
if (keepSub == (SV*)NULL)
/* First time, so create a new SV */
- keepSub = newSVsv(name) ;
+ keepSub = newSVsv(name);
else
/* Been here before, so overwrite */
- SvSetSV(keepSub, name) ;
+ SvSetSV(keepSub, name);
void
CallSavedSub2()
CODE:
- PUSHMARK(SP) ;
- call_sv(keepSub, G_DISCARD|G_NOARGS) ;
+ PUSHMARK(SP);
+ call_sv(keepSub, G_DISCARD|G_NOARGS);
To avoid creating a new SV every time C<SaveSub2> is called,
the function first checks to see if it has been called before. If not,
@@ -1167,7 +1167,7 @@ to it.
sub PrintList
{
- my(@list) = @_ ;
+ my(@list) = @_;
foreach (@list) { print "$_\n" }
}
@@ -1175,14 +1175,14 @@ to it.
and here is an example of I<call_argv> which will call
I<PrintList>.
- static char * words[] = {"alpha", "beta", "gamma", "delta", NULL} ;
+ static char * words[] = {"alpha", "beta", "gamma", "delta", NULL};
static void
call_PrintList()
{
- dSP ;
+ dSP;
- call_argv("PrintList", G_DISCARD, words) ;
+ call_argv("PrintList", G_DISCARD, words);
}
Note that it is not necessary to call C<PUSHMARK> in this instance.
@@ -1193,24 +1193,24 @@ This is because I<call_argv> will do it for you.
Consider the following Perl code
{
- package Mine ;
+ package Mine;
sub new
{
- my($type) = shift ;
+ my($type) = shift;
bless [@_]
}
sub Display
{
- my ($self, $index) = @_ ;
- print "$index: $$self[$index]\n" ;
+ my ($self, $index) = @_;
+ print "$index: $$self[$index]\n";
}
sub PrintID
{
- my($class) = @_ ;
- print "This is Class $class version 1.0\n" ;
+ my($class) = @_;
+ print "This is Class $class version 1.0\n";
}
}
@@ -1220,8 +1220,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 = new Mine ('red', 'green', 'blue') ;
- $a->Display(1) ;
+ $a = new Mine ('red', 'green', 'blue');
+ $a->Display(1);
PrintID Mine;
will print
@@ -1260,10 +1260,10 @@ the C<PrintID> and C<Display> methods from C.
CODE:
PUSHMARK(SP);
XPUSHs(ref);
- XPUSHs(sv_2mortal(newSViv(index))) ;
+ XPUSHs(sv_2mortal(newSViv(index)));
PUTBACK;
- call_method(method, G_DISCARD) ;
+ call_method(method, G_DISCARD);
void
call_PrintID(class, method)
@@ -1271,17 +1271,17 @@ the C<PrintID> and C<Display> methods from C.
char * method
CODE:
PUSHMARK(SP);
- XPUSHs(sv_2mortal(newSVpv(class, 0))) ;
+ XPUSHs(sv_2mortal(newSVpv(class, 0)));
PUTBACK;
- call_method(method, G_DISCARD) ;
+ call_method(method, G_DISCARD);
So the methods C<PrintID> and C<Display> can be invoked like this
- $a = new Mine ('red', 'green', 'blue') ;
- call_Method($a, 'Display', 1) ;
- call_PrintID('Mine', 'PrintID') ;
+ $a = new Mine ('red', 'green', 'blue');
+ call_Method($a, 'Display', 1);
+ call_PrintID('Mine', 'PrintID');
The only thing to note is that in both the static and virtual methods,
the method name is not passed via the stack--it is used as the first
@@ -1297,17 +1297,17 @@ currently executing.
CODE:
I32 gimme = GIMME_V;
if (gimme == G_VOID)
- printf ("Context is Void\n") ;
+ printf ("Context is Void\n");
else if (gimme == G_SCALAR)
- printf ("Context is Scalar\n") ;
+ printf ("Context is Scalar\n");
else
- printf ("Context is Array\n") ;
+ printf ("Context is Array\n");
and here is some Perl to test it
- PrintContext ;
- $a = PrintContext ;
- @a = PrintContext ;
+ PrintContext;
+ $a = PrintContext;
+ @a = PrintContext;
The output from that will be
@@ -1338,11 +1338,11 @@ There is another method which can be used, namely letting Perl do it
for you automatically whenever it regains control after the callback
has terminated. This is done by simply not using the
- ENTER ;
- SAVETMPS ;
+ ENTER;
+ SAVETMPS;
...
- FREETMPS ;
- LEAVE ;
+ FREETMPS;
+ LEAVE;
sequence in the callback (and not, of course, specifying the G_DISCARD
flag).
@@ -1441,7 +1441,7 @@ to a function as one of its parameters. Below is a call to a
hypothetical function C<register_fatal> which registers the C function
to get called when a fatal error occurs.
- register_fatal(cb1) ;
+ register_fatal(cb1);
The single parameter C<cb1> is a pointer to a function, so you must
have defined C<cb1> in your code, say something like this
@@ -1449,8 +1449,8 @@ have defined C<cb1> in your code, say something like this
static void
cb1()
{
- printf ("Fatal Error\n") ;
- exit(1) ;
+ printf ("Fatal Error\n");
+ exit(1);
}
Now change that to call a Perl subroutine instead
@@ -1460,12 +1460,12 @@ Now change that to call a Perl subroutine instead
static void
cb1()
{
- dSP ;
+ dSP;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
/* Call the Perl sub to process the callback */
- call_sv(callback, G_DISCARD) ;
+ call_sv(callback, G_DISCARD);
}
@@ -1475,22 +1475,22 @@ Now change that to call a Perl subroutine instead
CODE:
/* Remember the Perl sub */
if (callback == (SV*)NULL)
- callback = newSVsv(fn) ;
+ callback = newSVsv(fn);
else
- SvSetSV(callback, fn) ;
+ SvSetSV(callback, fn);
/* register the callback with the external library */
- register_fatal(cb1) ;
+ register_fatal(cb1);
where the Perl equivalent of C<register_fatal> and the callback it
registers, C<pcb1>, might look like this
# Register the sub pcb1
- register_fatal(\&pcb1) ;
+ register_fatal(\&pcb1);
sub pcb1
{
- die "I'm dying...\n" ;
+ die "I'm dying...\n";
}
The mapping between the C callback and the Perl equivalent is stored in
@@ -1522,8 +1522,8 @@ This may expect the C I<ProcessRead> function of this form
void
ProcessRead(fh, buffer)
- int fh ;
- char * buffer ;
+ int fh;
+ char * buffer;
{
...
}
@@ -1533,7 +1533,7 @@ between the C<fh> parameter and the Perl subroutine we want called. A
hash is a convenient mechanism for storing this mapping. The code
below shows a possible implementation
- static HV * Mapping = (HV*)NULL ;
+ static HV * Mapping = (HV*)NULL;
void
asynch_read(fh, callback)
@@ -1542,36 +1542,36 @@ below shows a possible implementation
CODE:
/* If the hash doesn't already exist, create it */
if (Mapping == (HV*)NULL)
- Mapping = newHV() ;
+ Mapping = newHV();
/* Save the fh -> callback mapping */
- hv_store(Mapping, (char*)&fh, sizeof(fh), newSVsv(callback), 0) ;
+ hv_store(Mapping, (char*)&fh, sizeof(fh), newSVsv(callback), 0);
/* Register with the C Library */
- asynch_read(fh, asynch_read_if) ;
+ asynch_read(fh, asynch_read_if);
and C<asynch_read_if> could look like this
static void
asynch_read_if(fh, buffer)
- int fh ;
- char * buffer ;
+ int fh;
+ char * buffer;
{
- dSP ;
- SV ** sv ;
+ dSP;
+ SV ** sv;
/* Get the callback associated with fh */
- sv = hv_fetch(Mapping, (char*)&fh , sizeof(fh), FALSE) ;
+ sv = hv_fetch(Mapping, (char*)&fh , sizeof(fh), FALSE);
if (sv == (SV**)NULL)
- croak("Internal error...\n") ;
+ croak("Internal error...\n");
- PUSHMARK(SP) ;
- XPUSHs(sv_2mortal(newSViv(fh))) ;
- XPUSHs(sv_2mortal(newSVpv(buffer, 0))) ;
- PUTBACK ;
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSViv(fh)));
+ XPUSHs(sv_2mortal(newSVpv(buffer, 0)));
+ PUTBACK;
/* Call the Perl sub */
- call_sv(*sv, G_DISCARD) ;
+ call_sv(*sv, G_DISCARD);
}
For completeness, here is C<asynch_close>. This shows how to remove
@@ -1582,22 +1582,22 @@ the entry from the hash C<Mapping>.
int fh
CODE:
/* Remove the entry from the hash */
- (void) hv_delete(Mapping, (char*)&fh, sizeof(fh), G_DISCARD) ;
+ (void) hv_delete(Mapping, (char*)&fh, sizeof(fh), G_DISCARD);
/* Now call the real asynch_close */
- asynch_close(fh) ;
+ asynch_close(fh);
So the Perl interface would look like this
sub callback1
{
- my($handle, $buffer) = @_ ;
+ my($handle, $buffer) = @_;
}
# Register the Perl callback
- asynch_read($fh, \&callback1) ;
+ asynch_read($fh, \&callback1);
- asynch_close($fh) ;
+ asynch_close($fh);
The mapping between the C callback and Perl is stored in the global
hash C<Mapping> this time. Using a hash has the distinct advantage that
@@ -1610,7 +1610,7 @@ the C<buffer> parameter like this
void
ProcessRead(buffer)
- char * buffer ;
+ char * buffer;
{
...
}
@@ -1623,59 +1623,59 @@ series of C functions to act as the interface to Perl, thus
#define MAX_CB 3
#define NULL_HANDLE -1
- typedef void (*FnMap)() ;
+ typedef void (*FnMap)();
struct MapStruct {
- FnMap Function ;
- SV * PerlSub ;
- int Handle ;
- } ;
+ FnMap Function;
+ SV * PerlSub;
+ int Handle;
+ };
- static void fn1() ;
- static void fn2() ;
- static void fn3() ;
+ static void fn1();
+ static void fn2();
+ static void fn3();
static struct MapStruct Map [MAX_CB] =
{
{ fn1, NULL, NULL_HANDLE },
{ fn2, NULL, NULL_HANDLE },
{ fn3, NULL, NULL_HANDLE }
- } ;
+ };
static void
Pcb(index, buffer)
- int index ;
- char * buffer ;
+ int index;
+ char * buffer;
{
- dSP ;
+ dSP;
- PUSHMARK(SP) ;
- XPUSHs(sv_2mortal(newSVpv(buffer, 0))) ;
- PUTBACK ;
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSVpv(buffer, 0)));
+ PUTBACK;
/* Call the Perl sub */
- call_sv(Map[index].PerlSub, G_DISCARD) ;
+ call_sv(Map[index].PerlSub, G_DISCARD);
}
static void
fn1(buffer)
- char * buffer ;
+ char * buffer;
{
- Pcb(0, buffer) ;
+ Pcb(0, buffer);
}
static void
fn2(buffer)
- char * buffer ;
+ char * buffer;
{
- Pcb(1, buffer) ;
+ Pcb(1, buffer);
}
static void
fn3(buffer)
- char * buffer ;
+ char * buffer;
{
- Pcb(2, buffer) ;
+ Pcb(2, buffer);
}
void
@@ -1683,55 +1683,55 @@ series of C functions to act as the interface to Perl, thus
int fh
SV * callback
CODE:
- int index ;
- int null_index = MAX_CB ;
+ int index;
+ int null_index = MAX_CB;
/* Find the same handle or an empty entry */
- for (index = 0 ; index < MAX_CB ; ++index)
+ for (index = 0; index < MAX_CB; ++index)
{
if (Map[index].Handle == fh)
- break ;
+ break;
if (Map[index].Handle == NULL_HANDLE)
- null_index = index ;
+ null_index = index;
}
if (index == MAX_CB && null_index == MAX_CB)
- croak ("Too many callback functions registered\n") ;
+ croak ("Too many callback functions registered\n");
if (index == MAX_CB)
- index = null_index ;
+ index = null_index;
/* Save the file handle */
- Map[index].Handle = fh ;
+ Map[index].Handle = fh;
/* Remember the Perl sub */
if (Map[index].PerlSub == (SV*)NULL)
- Map[index].PerlSub = newSVsv(callback) ;
+ Map[index].PerlSub = newSVsv(callback);
else
- SvSetSV(Map[index].PerlSub, callback) ;
+ SvSetSV(Map[index].PerlSub, callback);
- asynch_read(fh, Map[index].Function) ;
+ asynch_read(fh, Map[index].Function);
void
array_asynch_close(fh)
int fh
CODE:
- int index ;
+ int index;
/* Find the file handle */
- for (index = 0; index < MAX_CB ; ++ index)
+ for (index = 0; index < MAX_CB; ++ index)
if (Map[index].Handle == fh)
- break ;
+ break;
if (index == MAX_CB)
- croak ("could not close fh %d\n", fh) ;
+ croak ("could not close fh %d\n", fh);
- Map[index].Handle = NULL_HANDLE ;
- SvREFCNT_dec(Map[index].PerlSub) ;
- Map[index].PerlSub = (SV*)NULL ;
+ Map[index].Handle = NULL_HANDLE;
+ SvREFCNT_dec(Map[index].PerlSub);
+ Map[index].PerlSub = (SV*)NULL;
- asynch_close(fh) ;
+ asynch_close(fh);
In this case the functions C<fn1>, C<fn2>, and C<fn3> are used to
remember the Perl subroutine to be called. Each of the functions holds
@@ -1793,36 +1793,36 @@ of values> recoded to use C<ST> instead of C<POP*>.
static void
call_AddSubtract2(a, b)
- int a ;
- int b ;
+ int a;
+ int b;
{
- dSP ;
- I32 ax ;
- int count ;
+ dSP;
+ I32 ax;
+ int count;
- ENTER ;
+ ENTER;
SAVETMPS;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
- PUTBACK ;
+ PUTBACK;
count = call_pv("AddSubtract", G_ARRAY);
- SPAGAIN ;
- SP -= count ;
- ax = (SP - PL_stack_base) + 1 ;
+ SPAGAIN;
+ SP -= count;
+ ax = (SP - PL_stack_base) + 1;
if (count != 2)
- croak("Big trouble\n") ;
+ croak("Big trouble\n");
- printf ("%d + %d = %d\n", a, b, SvIV(ST(0))) ;
- printf ("%d - %d = %d\n", a, b, SvIV(ST(1))) ;
+ printf ("%d + %d = %d\n", a, b, SvIV(ST(0)));
+ printf ("%d - %d = %d\n", a, b, SvIV(ST(1)));
- PUTBACK ;
- FREETMPS ;
- LEAVE ;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
}
Notes
@@ -1840,9 +1840,9 @@ you.
The code
- SPAGAIN ;
- SP -= count ;
- ax = (SP - PL_stack_base) + 1 ;
+ SPAGAIN;
+ SP -= count;
+ ax = (SP - PL_stack_base) + 1;
sets the stack up so that we can use the C<ST> macro.
diff --git a/pod/perldbmfilter.pod b/pod/perldbmfilter.pod
index d62e496f9f..f145b8aa1b 100644
--- a/pod/perldbmfilter.pod
+++ b/pod/perldbmfilter.pod
@@ -6,10 +6,10 @@ perldbmfilter - Perl DBM Filters
$db = tie %hash, 'DBM', ...
- $old_filter = $db->filter_store_key ( sub { ... } ) ;
- $old_filter = $db->filter_store_value( sub { ... } ) ;
- $old_filter = $db->filter_fetch_key ( sub { ... } ) ;
- $old_filter = $db->filter_fetch_value( sub { ... } ) ;
+ $old_filter = $db->filter_store_key ( sub { ... } );
+ $old_filter = $db->filter_store_value( sub { ... } );
+ $old_filter = $db->filter_fetch_key ( sub { ... } );
+ $old_filter = $db->filter_fetch_value( sub { ... } );
=head1 DESCRIPTION
@@ -73,7 +73,7 @@ when Perl writes to DBM databases it doesn't use NULL termination, so
your Perl application will have to manage NULL termination itself. When
you write to the database you will have to use something like this:
- $hash{"$key\0"} = "$value\0" ;
+ $hash{"$key\0"} = "$value\0";
Similarly the NULL needs to be taken into account when you are considering
the length of existing keys/values.
@@ -85,30 +85,30 @@ the database and have them removed when you read from the database. As I'm
sure you have already guessed, this is a problem that DBM Filters can
fix very easily.
- use strict ;
- use warnings ;
- use SDBM_File ;
- use Fcntl ;
+ use strict;
+ use warnings;
+ use SDBM_File;
+ use Fcntl;
- my %hash ;
- my $filename = "filt" ;
- unlink $filename ;
+ my %hash;
+ my $filename = "filt";
+ unlink $filename;
my $db = tie(%hash, 'SDBM_File', $filename, O_RDWR|O_CREAT, 0640)
- or die "Cannot open $filename: $!\n" ;
+ or die "Cannot open $filename: $!\n";
# Install DBM Filters
- $db->filter_fetch_key ( sub { s/\0$// } ) ;
- $db->filter_store_key ( sub { $_ .= "\0" } ) ;
+ $db->filter_fetch_key ( sub { s/\0$// } );
+ $db->filter_store_key ( sub { $_ .= "\0" } );
$db->filter_fetch_value(
- sub { no warnings 'uninitialized' ;s/\0$// } ) ;
- $db->filter_store_value( sub { $_ .= "\0" } ) ;
+ sub { no warnings 'uninitialized'; s/\0$// } );
+ $db->filter_store_value( sub { $_ .= "\0" } );
- $hash{"abc"} = "def" ;
- my $a = $hash{"ABC"} ;
+ $hash{"abc"} = "def";
+ my $a = $hash{"ABC"};
# ...
- undef $db ;
- untie %hash ;
+ undef $db;
+ untie %hash;
The code above uses SDBM_File, but it will work with any of the DBM
modules.
@@ -124,7 +124,7 @@ Here is another real-life example. By default, whenever Perl writes to
a DBM database it always writes the key and value as strings. So when
you use this:
- $hash{12345} = "something" ;
+ $hash{12345} = "something";
the key 12345 will get stored in the DBM database as the 5 byte string
"12345". If you actually want the key to be stored in the DBM database
@@ -133,23 +133,23 @@ when reading.
Here is a DBM Filter that does it:
- use strict ;
- use warnings ;
- use DB_File ;
- my %hash ;
- my $filename = "filt" ;
- unlink $filename ;
+ use strict;
+ use warnings;
+ use DB_File;
+ my %hash;
+ my $filename = "filt";
+ unlink $filename;
my $db = tie %hash, 'DB_File', $filename, O_CREAT|O_RDWR, 0666, $DB_HASH
- or die "Cannot open $filename: $!\n" ;
+ or die "Cannot open $filename: $!\n";
- $db->filter_fetch_key ( sub { $_ = unpack("i", $_) } ) ;
- $db->filter_store_key ( sub { $_ = pack ("i", $_) } ) ;
- $hash{123} = "def" ;
+ $db->filter_fetch_key ( sub { $_ = unpack("i", $_) } );
+ $db->filter_store_key ( sub { $_ = pack ("i", $_) } );
+ $hash{123} = "def";
# ...
- undef $db ;
- untie %hash ;
+ undef $db;
+ untie %hash;
The code above uses DB_File, but again it will work with any of the
DBM modules.
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 5c2c1d2be1..6e5207f5ef 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -4344,7 +4344,7 @@ L<perlref> for more on this.
This warning will not be issued for numerical constants equal to 0 or 1
since they are often used in statements like
- 1 while sub_with_side_effects() ;
+ 1 while sub_with_side_effects();
String constants that would normally evaluate to 0 or 1 are warned
about.
diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod
index 31db204129..da725a70bb 100644
--- a/pod/perlfaq5.pod
+++ b/pod/perlfaq5.pod
@@ -57,7 +57,7 @@ thing you do with them. You can use IO::Handle:
or IO::Socket:
use IO::Socket; # this one is kinda a pipe?
- my $sock = IO::Socket::INET->new( 'www.example.com:80' ) ;
+ my $sock = IO::Socket::INET->new( 'www.example.com:80' );
$sock->autoflush();
diff --git a/pod/perlfilter.pod b/pod/perlfilter.pod
index 51cd8ced75..d43028c2a5 100644
--- a/pod/perlfilter.pod
+++ b/pod/perlfilter.pod
@@ -89,10 +89,10 @@ Below is an example program, C<cpp_test>, which makes use of this filter.
Line numbers have been added to allow specific lines to be referenced
easily.
- 1: use Filter::cpp ;
+ 1: use Filter::cpp;
2: #define TRUE 1
- 3: $a = TRUE ;
- 4: print "a = $a\n" ;
+ 3: $a = TRUE;
+ 4: print "a = $a\n";
When you execute this script, Perl creates a source stream for the
file. Before the parser processes any of the lines from the file, the
@@ -122,18 +122,18 @@ inserted back into the source stream by the filter.
The parser then sees the following code:
- use Filter::cpp ;
- $a = 1 ;
- print "a = $a\n" ;
+ use Filter::cpp;
+ $a = 1;
+ print "a = $a\n";
Let's consider what happens when the filtered code includes another
module with use:
- 1: use Filter::cpp ;
+ 1: use Filter::cpp;
2: #define TRUE 1
- 3: use Fred ;
- 4: $a = TRUE ;
- 5: print "a = $a\n" ;
+ 3: use Fred;
+ 4: $a = TRUE;
+ 5: print "a = $a\n";
The C<cpp> filter does not apply to the text of the Fred module, only
to the text of the file that used it (C<cpp_test>). Although the use
@@ -160,7 +160,7 @@ For example, if you have a uuencoded and compressed source file, it is
possible to stack a uudecode filter and an uncompression filter like
this:
- use Filter::uudecode ; use Filter::uncompress ;
+ use Filter::uudecode; use Filter::uncompress;
M'XL(".H<US4''V9I;F%L')Q;>7/;1I;_>_I3=&E=%:F*I"T?22Q/
M6]9*<IQCO*XFT"0[PL%%'Y+IG?WN^ZYN-$'J.[.JE$,20/?K=_[>
...
@@ -245,9 +245,9 @@ redirection facilities.
Here is an example script that uses C<Filter::sh>:
- use Filter::sh 'tr XYZ PQR' ;
- $a = 1 ;
- print "XYZ a = $a\n" ;
+ use Filter::sh 'tr XYZ PQR';
+ $a = 1;
+ print "XYZ a = $a\n";
The output you'll get when the script is executed:
@@ -274,23 +274,23 @@ forward thirteen places, so that A becomes N, B becomes O, and Z
becomes M.)
- package Rot13 ;
+ package Rot13;
- use Filter::Util::Call ;
+ use Filter::Util::Call;
sub import {
- my ($type) = @_ ;
- my ($ref) = [] ;
- filter_add(bless $ref) ;
+ my ($type) = @_;
+ my ($ref) = [];
+ filter_add(bless $ref);
}
sub filter {
- my ($self) = @_ ;
- my ($status) ;
+ my ($self) = @_;
+ my ($status);
tr/n-za-mN-ZA-M/a-zA-Z/
- if ($status = filter_read()) > 0 ;
- $status ;
+ if ($status = filter_read()) > 0;
+ $status;
}
1;
@@ -339,16 +339,16 @@ In order to make use of the rot13 filter we need some way of encoding
the source file in rot13 format. The script below, C<mkrot13>, does
just that.
- die "usage mkrot13 filename\n" unless @ARGV ;
- my $in = $ARGV[0] ;
- my $out = "$in.tmp" ;
+ die "usage mkrot13 filename\n" unless @ARGV;
+ my $in = $ARGV[0];
+ my $out = "$in.tmp";
open(IN, "<$in") or die "Cannot open file $in: $!\n";
open(OUT, ">$out") or die "Cannot open file $out: $!\n";
- print OUT "use Rot13;\n" ;
+ print OUT "use Rot13;\n";
while (<IN>) {
- tr/a-zA-Z/n-za-mN-ZA-M/ ;
- print OUT ;
+ tr/a-zA-Z/n-za-mN-ZA-M/;
+ print OUT;
}
close IN;
@@ -358,12 +358,12 @@ just that.
If we encrypt this with C<mkrot13>:
- print " hello fred \n" ;
+ print " hello fred \n";
the result will be this:
use Rot13;
- cevag "uryyb serq\a" ;
+ cevag "uryyb serq\a";
Running it produces this output:
@@ -385,7 +385,7 @@ Two special marker lines will bracket debugging code, like this:
## DEBUG_BEGIN
if ($year > 1999) {
- warn "Debug: millennium bug in year $year\n" ;
+ warn "Debug: millennium bug in year $year\n";
}
## DEBUG_END
@@ -400,7 +400,7 @@ between the two markers into comments:
## DEBUG_BEGIN
#if ($year > 1999) {
- # warn "Debug: millennium bug in year $year\n" ;
+ # warn "Debug: millennium bug in year $year\n";
#}
## DEBUG_END
@@ -410,62 +410,62 @@ Here is the complete Debug filter:
use strict;
use warnings;
- use Filter::Util::Call ;
+ use Filter::Util::Call;
- use constant TRUE => 1 ;
- use constant FALSE => 0 ;
+ use constant TRUE => 1;
+ use constant FALSE => 0;
sub import {
- my ($type) = @_ ;
+ my ($type) = @_;
my (%context) = (
Enabled => defined $ENV{DEBUG},
InTraceBlock => FALSE,
Filename => (caller)[1],
LineNo => 0,
LastBegin => 0,
- ) ;
- filter_add(bless \%context) ;
+ );
+ filter_add(bless \%context);
}
sub Die {
- my ($self) = shift ;
- my ($message) = shift ;
- my ($line_no) = shift || $self->{LastBegin} ;
+ my ($self) = shift;
+ my ($message) = shift;
+ my ($line_no) = shift || $self->{LastBegin};
die "$message at $self->{Filename} line $line_no.\n"
}
sub filter {
- my ($self) = @_ ;
- my ($status) ;
- $status = filter_read() ;
- ++ $self->{LineNo} ;
+ my ($self) = @_;
+ my ($status);
+ $status = filter_read();
+ ++ $self->{LineNo};
# deal with EOF/error first
if ($status <= 0) {
$self->Die("DEBUG_BEGIN has no DEBUG_END")
- if $self->{InTraceBlock} ;
- return $status ;
+ if $self->{InTraceBlock};
+ return $status;
}
if ($self->{InTraceBlock}) {
if (/^\s*##\s*DEBUG_BEGIN/ ) {
$self->Die("Nested DEBUG_BEGIN", $self->{LineNo})
} elsif (/^\s*##\s*DEBUG_END/) {
- $self->{InTraceBlock} = FALSE ;
+ $self->{InTraceBlock} = FALSE;
}
# comment out the debug lines when the filter is disabled
- s/^/#/ if ! $self->{Enabled} ;
+ s/^/#/ if ! $self->{Enabled};
} elsif ( /^\s*##\s*DEBUG_BEGIN/ ) {
- $self->{InTraceBlock} = TRUE ;
- $self->{LastBegin} = $self->{LineNo} ;
+ $self->{InTraceBlock} = TRUE;
+ $self->{LastBegin} = $self->{LineNo};
} elsif ( /^\s*##\s*DEBUG_END/ ) {
$self->Die("DEBUG_END has no DEBUG_BEGIN", $self->{LineNo});
}
- return $status ;
+ return $status;
}
- 1 ;
+ 1;
The big difference between this filter and the previous example is the
use of context data in the filter object. The filter object is based on
@@ -481,23 +481,23 @@ If you ignore all the error checking that most of the code does, the
essence of the filter is as follows:
sub filter {
- my ($self) = @_ ;
- my ($status) ;
- $status = filter_read() ;
+ my ($self) = @_;
+ my ($status);
+ $status = filter_read();
# deal with EOF/error first
- return $status if $status <= 0 ;
+ return $status if $status <= 0;
if ($self->{InTraceBlock}) {
if (/^\s*##\s*DEBUG_END/) {
$self->{InTraceBlock} = FALSE
}
# comment out debug lines when the filter is disabled
- s/^/#/ if ! $self->{Enabled} ;
+ s/^/#/ if ! $self->{Enabled};
} elsif ( /^\s*##\s*DEBUG_BEGIN/ ) {
- $self->{InTraceBlock} = TRUE ;
+ $self->{InTraceBlock} = TRUE;
}
- return $status ;
+ return $status;
}
Be warned: just as the C-preprocessor doesn't know C, the Debug filter
@@ -539,9 +539,9 @@ parameter list. Such a filter would turn this:
into this:
sub MySub($$@) {
- my ($first) = shift ;
- my ($second) = shift ;
- my (@rest) = @_ ;
+ my ($first) = shift;
+ my ($second) = shift;
+ my (@rest) = @_;
...
}
diff --git a/pod/perlipc.pod b/pod/perlipc.pod
index 671da85f75..a0357e0e56 100644
--- a/pod/perlipc.pod
+++ b/pod/perlipc.pod
@@ -1012,7 +1012,7 @@ differ from the system on which it's being run:
my $rtime = ' ';
read(SOCKET, $rtime, 4);
close(SOCKET);
- my $histime = unpack("N", $rtime) - $SECS_of_70_YEARS ;
+ my $histime = unpack("N", $rtime) - $SECS_of_70_YEARS;
printf "%8d %s\n", $histime - time, ctime($histime);
}
@@ -1516,7 +1516,7 @@ with TCP, you'd have to use a different socket handle for each host.
($hispaddr = recv(SOCKET, $rtime, 4, 0)) || die "recv: $!";
($port, $hisiaddr) = sockaddr_in($hispaddr);
$host = gethostbyaddr($hisiaddr, AF_INET);
- $histime = unpack("N", $rtime) - $SECS_of_70_YEARS ;
+ $histime = unpack("N", $rtime) - $SECS_of_70_YEARS;
printf "%-12s ", $host;
printf "%8d %s\n", $histime - time, scalar localtime($histime);
$count--;
diff --git a/pod/perllexwarn.pod b/pod/perllexwarn.pod
index 8274c4d70e..20f1875c0c 100644
--- a/pod/perllexwarn.pod
+++ b/pod/perllexwarn.pod
@@ -20,21 +20,21 @@ doesn't attempt to control the warnings will work unchanged.
All warnings are enabled in a block by either of these:
- use warnings ;
- use warnings 'all' ;
+ use warnings;
+ use warnings 'all';
Similarly all warnings are disabled in a block by either of these:
- no warnings ;
- no warnings 'all' ;
+ no warnings;
+ no warnings 'all';
For example, consider the code below:
- use warnings ;
- my @a ;
+ use warnings;
+ my @a;
{
- no warnings ;
- my $b = @a[0] ;
+ no warnings;
+ my $b = @a[0];
}
my $c = @a[0];
@@ -63,7 +63,7 @@ example, in the code below, an C<"isn't numeric"> warning will only
be reported for the C<$a> variable.
my $a = "2:" + 3;
- no warnings ;
+ no warnings;
my $b = "2:" + 3;
Note that neither the B<-w> flag or the C<$^W> can be used to
@@ -83,9 +83,9 @@ fundamentally flawed. For a start, say you want to disable warnings in
a block of code. You might expect this to be enough to do the trick:
{
- local ($^W) = 0 ;
- my $a =+ 2 ;
- my $b ; chop $b ;
+ local ($^W) = 0;
+ my $a =+ 2;
+ my $b; chop $b;
}
When this code is run with the B<-w> flag, a warning will be produced
@@ -96,8 +96,8 @@ disable compile-time warnings you need to rewrite the code like this:
{
BEGIN { $^W = 0 }
- my $a =+ 2 ;
- my $b ; chop $b ;
+ my $a =+ 2;
+ my $b; chop $b;
}
The other big problem with C<$^W> is the way you can inadvertently
@@ -108,13 +108,13 @@ the first will not.
sub doit
{
- my $b ; chop $b ;
+ my $b; chop $b;
}
- doit() ;
+ doit();
{
- local ($^W) = 1 ;
+ local ($^W) = 1;
doit()
}
@@ -306,17 +306,17 @@ The current hierarchy is:
Just like the "strict" pragma any of these categories can be combined
- use warnings qw(void redefine) ;
- no warnings qw(io syntax untie) ;
+ use warnings qw(void redefine);
+ no warnings qw(io syntax untie);
Also like the "strict" pragma, if there is more than one instance of the
C<warnings> pragma in a given scope the cumulative effect is additive.
- use warnings qw(void) ; # only "void" warnings enabled
+ use warnings qw(void); # only "void" warnings enabled
...
- use warnings qw(io) ; # only "void" & "io" warnings enabled
+ use warnings qw(io); # only "void" & "io" warnings enabled
...
- no warnings qw(void) ; # only "io" warnings enabled
+ no warnings qw(void); # only "io" warnings enabled
To determine which category a specific warning has been assigned to see
L<perldiag>.
@@ -335,18 +335,18 @@ into fatal errors. In the code below, the use of C<time>, C<length>
and C<join> can all produce a C<"Useless use of xxx in void context">
warning.
- use warnings ;
+ use warnings;
- time ;
+ time;
{
- use warnings FATAL => qw(void) ;
- length "abc" ;
+ use warnings FATAL => qw(void);
+ length "abc";
}
- join "", 1,2,3 ;
+ join "", 1,2,3;
- print "done\n" ;
+ print "done\n";
When run it produces this output
@@ -386,7 +386,7 @@ Consider the module C<MyMod::Abc> below.
use warnings::register;
sub open {
- my $path = shift ;
+ my $path = shift;
if ($path !~ m#^/#) {
warnings::warn("changing relative path to /var/abc")
if warnings::enabled();
@@ -394,7 +394,7 @@ Consider the module C<MyMod::Abc> below.
}
}
- 1 ;
+ 1;
The call to C<warnings::register> will create a new warnings category
called "MyMod::abc", i.e. the new category name matches the current
@@ -416,13 +416,13 @@ this snippet of code:
sub open {
warnings::warnif("deprecated",
- "open is deprecated, use new instead") ;
- new(@_) ;
+ "open is deprecated, use new instead");
+ new(@_);
}
sub new
...
- 1 ;
+ 1;
The function C<open> has been deprecated, so code has been included to
display a warning message whenever the calling module has (at least) the
@@ -431,7 +431,7 @@ display a warning message whenever the calling module has (at least) the
use warnings 'deprecated';
use MyMod::Abc;
...
- MyMod::Abc::open($filename) ;
+ MyMod::Abc::open($filename);
Either the C<warnings::warn> or C<warnings::warnif> function should be
used to actually display the warnings message. This is because they can
@@ -453,21 +453,21 @@ of the object as the warnings category.
Consider this example:
- package Original ;
+ package Original;
- no warnings ;
- use warnings::register ;
+ no warnings;
+ use warnings::register;
sub new
{
- my $class = shift ;
- bless [], $class ;
+ my $class = shift;
+ bless [], $class;
}
sub check
{
- my $self = shift ;
- my $value = shift ;
+ my $self = shift;
+ my $value = shift;
if ($value % 2 && warnings::enabled($self))
{ warnings::warn($self, "Odd numbers are unsafe") }
@@ -475,38 +475,38 @@ Consider this example:
sub doit
{
- my $self = shift ;
- my $value = shift ;
- $self->check($value) ;
+ my $self = shift;
+ my $value = shift;
+ $self->check($value);
# ...
}
- 1 ;
+ 1;
- package Derived ;
+ package Derived;
- use warnings::register ;
- use Original ;
- our @ISA = qw( Original ) ;
+ use warnings::register;
+ use Original;
+ our @ISA = qw( Original );
sub new
{
- my $class = shift ;
- bless [], $class ;
+ my $class = shift;
+ bless [], $class;
}
- 1 ;
+ 1;
The code below makes use of both modules, but it only enables warnings from
C<Derived>.
- use Original ;
- use Derived ;
+ use Original;
+ use Derived;
use warnings 'Derived';
- my $a = new Original ;
- $a->doit(1) ;
- my $b = new Derived ;
- $a->doit(1) ;
+ my $a = new Original;
+ $a->doit(1);
+ my $b = new Derived;
+ $a->doit(1);
When this code is run only the C<Derived> object, C<$b>, will generate
a warning.
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 32a58b83a3..6aa762dfd0 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -2215,8 +2215,8 @@ you're supplying bitstrings: If an operand is a number, that will imply
a B<numeric> bitwise operation. You may explicitly show which type of
operation you intend by using C<""> or C<0+>, as in the examples below.
- $foo = 150 | 105 ; # yields 255 (0x96 | 0x69 is 0xFF)
- $foo = '150' | 105 ; # yields 255
+ $foo = 150 | 105; # yields 255 (0x96 | 0x69 is 0xFF)
+ $foo = '150' | 105; # yields 255
$foo = 150 | '105'; # yields 255
$foo = '150' | '105'; # yields string '155' (under ASCII)
diff --git a/pod/perlre.pod b/pod/perlre.pod
index 23a7b0fa71..f24e97157b 100644
--- a/pod/perlre.pod
+++ b/pod/perlre.pod
@@ -960,14 +960,14 @@ But that isn't going to match; at least, not the way you're hoping. It
claims that there is no 123 in the string. Here's a clearer picture of
why that pattern matches, contrary to popular expectations:
- $x = 'ABC123' ;
- $y = 'ABC445' ;
+ $x = 'ABC123';
+ $y = 'ABC445';
- print "1: got $1\n" if $x =~ /^(ABC)(?!123)/ ;
- print "2: got $1\n" if $y =~ /^(ABC)(?!123)/ ;
+ print "1: got $1\n" if $x =~ /^(ABC)(?!123)/;
+ print "2: got $1\n" if $y =~ /^(ABC)(?!123)/;
- print "3: got $1\n" if $x =~ /^(\D*)(?!123)/ ;
- print "4: got $1\n" if $y =~ /^(\D*)(?!123)/ ;
+ print "3: got $1\n" if $x =~ /^(\D*)(?!123)/;
+ print "4: got $1\n" if $y =~ /^(\D*)(?!123)/;
This prints
@@ -1002,8 +1002,8 @@ are zero-width expressions--they only look, but don't consume any
of the string in their match. So rewriting this way produces what
you'd expect; that is, case 5 will fail, but case 6 succeeds:
- print "5: got $1\n" if $x =~ /^(\D*)(?=\d)(?!123)/ ;
- print "6: got $1\n" if $y =~ /^(\D*)(?=\d)(?!123)/ ;
+ print "5: got $1\n" if $x =~ /^(\D*)(?=\d)(?!123)/;
+ print "6: got $1\n" if $y =~ /^(\D*)(?=\d)(?!123)/;
6: got ABC
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index 5054910297..71d6691e38 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -1400,17 +1400,17 @@ nest properly.
Examples of valid syntax (even though the attributes are unknown):
- sub fnord (&\%) : switch(10,foo(7,3)) : expensive ;
- sub plugh () : Ugly('\(") :Bad ;
+ sub fnord (&\%) : switch(10,foo(7,3)) : expensive;
+ sub plugh () : Ugly('\(") :Bad;
sub xyzzy : _5x5 { ... }
Examples of invalid syntax:
- sub fnord : switch(10,foo() ; # ()-string not balanced
- sub snoid : Ugly('(') ; # ()-string not balanced
- sub xyzzy : 5x5 ; # "5x5" not a valid identifier
- sub plugh : Y2::north ; # "Y2::north" not a simple identifier
- sub snurt : foo + bar ; # "+" not a colon or space
+ sub fnord : switch(10,foo(); # ()-string not balanced
+ sub snoid : Ugly('('); # ()-string not balanced
+ sub xyzzy : 5x5; # "5x5" not a valid identifier
+ sub plugh : Y2::north; # "Y2::north" not a simple identifier
+ sub snurt : foo + bar; # "+" not a colon or space
The attribute list is passed as a list of constant strings to the code
which associates them with the subroutine. In particular, the second example
diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index f5d1f83be4..3da025402f 100644
--- a/pod/perltrap.pod
+++ b/pod/perltrap.pod
@@ -448,8 +448,8 @@ Given that C<::> is now the preferred package delimiter, it is debatable
whether this should be classed as a bug or not.
(The older package delimiter, ' ,is used here)
- $x = 10 ;
- print "x=${'x}\n" ;
+ $x = 10;
+ print "x=${'x}\n";
# perl4 prints: x=10
# perl5 prints: Can't find string terminator "'" anywhere before EOF
@@ -457,8 +457,8 @@ whether this should be classed as a bug or not.
You can avoid this problem, and remain compatible with perl4, if you
always explicitly include the package name:
- $x = 10 ;
- print "x=${main'x}\n" ;
+ $x = 10;
+ print "x=${main'x}\n";
Also see precedence traps, for parsing C<$:>.
@@ -497,7 +497,7 @@ of a variable, or as a delimiter for any kind of quote construct.
Double darn.
$a = ("foo bar");
- $b = q baz ;
+ $b = q baz;
print "a is $a, b is $b\n";
# perl4 prints: a is foo bar, b is baz
@@ -1219,7 +1219,7 @@ C<[$opt]> is a character class in perl4 and an array subscript in perl5
$opt = 'r';
$_ = 'bar';
s/^([^$grpc]*$grpc[$opt]?)/foo/;
- print ;
+ print;
# perl4 prints: foo
# perl5 prints: foobar
@@ -1334,11 +1334,11 @@ for append, it is impossible to overwrite information already in
the file.
open(TEST,">>seek.test");
- $start = tell TEST ;
+ $start = tell TEST;
foreach(1 .. 9){
print TEST "$_ ";
}
- $end = tell TEST ;
+ $end = tell TEST;
seek(TEST,$start,0);
print TEST "18 characters here";
diff --git a/pod/perlxs.pod b/pod/perlxs.pod
index 7360c57d10..462f84ce3f 100644
--- a/pod/perlxs.pod
+++ b/pod/perlxs.pod
@@ -588,7 +588,7 @@ Here's a truly obscure example:
bool_t
rpcb_gettime(host,timep)
- time_t &timep ; /* \$v{timep}=@{[$v{timep}=$arg]} */
+ time_t &timep; /* \$v{timep}=@{[$v{timep}=$arg]} */
char *host + SvOK($v{timep}) ? SvPV($arg,PL_na) : NULL;
OUTPUT:
timep
@@ -1902,7 +1902,7 @@ Below is an example module that makes use of the macros.
dMY_CXT;
CODE:
if (MY_CXT.count >= 3) {
- warn("Already have 3 blind mice") ;
+ warn("Already have 3 blind mice");
RETVAL = 0;
}
else {