perl -w compile and run time checking 
Author Message
 perl -w compile and run time checking

The following short code snippet

$x = 1;
$y = ${ 'x' };
print "$y\n";

yields the following error when run with perl -w

Name "main::x" used only once: possible typo at c:\temp.pl line 1.

This is understandable in terms of perl doing compile time error
detection but does not really appear to be desireable behavior.

Is there any way to control perl's selection of warnings (eg turn
them off as with some 'C' compilers.  Can this be construed as
a bug?

Ron Schmidt
The Software Path




Thu, 25 Jan 2001 03:00:00 GMT  
 perl -w compile and run time checking

Quote:

>Is there any way to control perl's selection of warnings (eg turn
>them off as with some 'C' compilers.

There is a long talked about "lexical warning patch" that never seems
to make it into the main perl distribution. Maybe some day.

Until then, you can turn off this particular error by the "use vars"
pragma.

use vars '$x';

--
Andrew Langmead



Fri, 26 Jan 2001 03:00:00 GMT  
 perl -w compile and run time checking

RonaldWS schrieb in Nachricht

Quote:
>The following short code snippet

>$x = 1;
>$y = ${ 'x' };
>print "$y\n";

>yields the following error when run with perl -w

>Name "main::x" used only once: possible typo at c:\temp.pl line 1.

>This is understandable in terms of perl doing compile time error
>detection but does not really appear to be desireable behavior.

>Is there any way to control perl's selection of warnings (eg turn
>them off as with some 'C' compilers.  Can this be construed as
>a bug?

You can swith the -w on or off. In addition you can include "use
diagnostics;" to get more information.

If you don't like the upper warning: just double the first line.
$x=1;
$x=1;
or if you "use strict;":
use vars qw($x);

HTH



Fri, 26 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. require is at Run-Time but strict check is at Compile-Time

2. Compiling code at run-time, not compile-time

3. Extensions: run-time or compile-time???

4. Run time/Compile Problems with Perl/TK

5. Help: strict compile-time check of subroutine's existance

6. RETRY: manipulating @INC at perl5 compile time (not script compile time)

7. Run-time error after compile

8. Run Another CGI during Run-Time

9. Perl: time check question

10. perl check file time problem

11. is 'my' compile-time or run-time?

12. Perl 5 compile time error during make.

 

 
Powered by phpBB® Forum Software