Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: find all uninitialized variables?

Posted on 2006-02-23 00:12:14 by Harry Zhu

This is a multi-part message in MIME format.

------=_NextPart_000_07C6_01C637D3.2026AAF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Is there an easy way (a tool) to locate all uninitialized variables for =
modperl modules in a dirctory so I can initilized them and get rid of =
the annoying warnings? Googlling on the internet seems no useful =
results. Some one shield me a light?

Harry Zhu
------=_NextPart_000_07C6_01C637D3.2026AAF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Is there an easy way (a =
tool)&nbsp;to&nbsp;locate=20
all uninitialized variables&nbsp;for modperl modules in a =
dirctory&nbsp;so I can=20
initilized them and get rid of the annoying warnings? Googlling on the =
internet=20
seems no useful results. Some one shield me a light?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Harry Zhu</FONT></DIV></BODY></HTML>

------=_NextPart_000_07C6_01C637D3.2026AAF0--

Report this message

#2: RE: find all uninitialized variables?

Posted on 2006-02-23 00:17:21 by Frank Maas

>Is there an easy way (a tool) to locate all uninitialized variables for =
modperl=20
>modules in a dirctory so I can initilized them and get rid of the =
annoying=20
>warnings? Googlling on the internet seems no useful results. Some one =
shield=20
>me a light?
=20
Does not seem to be a specifiec mod_perl thing, but hey. Have you tried =
"use strict"?
If that does not do your trick, then elaborate on what you mean by =
'uninitialized'?

Gr/F

Report this message

#3: Re: find all uninitialized variables?

Posted on 2006-02-23 00:24:51 by Harry Zhu

"use strict" will find the undeclared/undefined variables.

something like
my $var;

and later on used in the program will not be find by the "use strict", but
will cause "use uninitialized variables" warnings if -w switch is on.

Harry




----- Original Message -----
From: "Frank Maas" <frank.maas@cheiron-it.nl>
To: "'Harry Zhu'" <harry@greatlodge.com>; <modperl@perl.apache.org>
Sent: Wednesday, February 22, 2006 5:17 PM
Subject: RE: find all uninitialized variables?



>Is there an easy way (a tool) to locate all uninitialized variables for
>modperl
>modules in a dirctory so I can initilized them and get rid of the annoying
>warnings? Googlling on the internet seems no useful results. Some one
>shield
>me a light?

Does not seem to be a specifiec mod_perl thing, but hey. Have you tried "use
strict"?
If that does not do your trick, then elaborate on what you mean by
'uninitialized'?

Gr/F




--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.0.0/266 - Release Date: 2/21/2006

Report this message

#4: Re: find all uninitialized variables?

Posted on 2006-02-23 00:27:22 by Tyler MacDonald

Harry Zhu <harry@greatlodge.com> wrote:
> "use strict" will find the undeclared/undefined variables.
>
> something like
> my $var;
>
> and later on used in the program will not be find by the "use strict", but
> will cause "use uninitialized variables" warnings if -w switch is on.

If you really want to cause your scripts to crash on every
uninitialized variable so you have to go in and fix it, you can do this:

use warnings FATAL => 'uninitialized';

Cheers,
Tyler

Report this message

#5: Re: find all uninitialized variables?

Posted on 2006-02-23 00:37:05 by Harry Zhu

Say I have a file directory with hundreds of modules, I want to know if
there is a tool I can scan and identify the uninitalized variables in all
the files once (or through a loop) without actually running through all the
pages.

Harry


----- Original Message -----
From: "Tyler MacDonald" <tyler@yi.org>
To: "Harry Zhu" <harry@greatlodge.com>
Cc: "Frank Maas" <frank.maas@cheiron-it.nl>; <modperl@perl.apache.org>
Sent: Wednesday, February 22, 2006 5:27 PM
Subject: Re: find all uninitialized variables?


> Harry Zhu <harry@greatlodge.com> wrote:
>> "use strict" will find the undeclared/undefined variables.
>>
>> something like
>> my $var;
>>
>> and later on used in the program will not be find by the "use strict",
>> but
>> will cause "use uninitialized variables" warnings if -w switch is on.
>
> If you really want to cause your scripts to crash on every
> uninitialized variable so you have to go in and fix it, you can do this:
>
> use warnings FATAL => 'uninitialized';
>
> Cheers,
> Tyler
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 268.0.0/266 - Release Date: 2/21/2006
>
>

Report this message

#6: Re: find all uninitialized variables?

Posted on 2006-02-23 00:47:45 by Ryan Gies

I've been frustrated with the "Use of uninitialized value" warning
myself, and was hoping someone could shed some light on it as well.
Point being, this will issue the warning:

#!/usr/bin/perl -Tw
sub max { return $_[0] > $_[1] ? $_[0] : $_[1]; }
max();

In what seems like logic, the undef value should behave like zero or
empty string when using operators like: '.' ',' 'eq' 'lt' '>' etc...

--- Yes, this should taken to beginners@perl.org ---

I believe the crux of Harry's problem is that warnings are only issued
as the code is executed, and we want to find unintialized variables
without having to make an uber test-case which calls every subroutine.

Anyway, here's a (I presume very frowned-upon) way to get around the
annoying warning messages, or maybe you can use it to silently capture
the warnings as your application runs over time:

$SIG{__WARN__} = \&_sigwarn; # notice not declared local!

sub _sigwarn {
my $msg = shift || return;
return if $msg =~ "^Use of uninitialized value in";
print STDERR $msg;
}

Harry Zhu wrote:
> "use strict" will find the undeclared/undefined variables.
>
> something like
> my $var;
>
> and later on used in the program will not be find by the "use strict",
> but will cause "use uninitialized variables" warnings if -w switch is on.
>
> Harry
>
>
>
>
> ----- Original Message ----- From: "Frank Maas" <frank.maas@cheiron-it.nl>
> To: "'Harry Zhu'" <harry@greatlodge.com>; <modperl@perl.apache.org>
> Sent: Wednesday, February 22, 2006 5:17 PM
> Subject: RE: find all uninitialized variables?
>
>
>
>> Is there an easy way (a tool) to locate all uninitialized variables
>> for modperl
>> modules in a dirctory so I can initilized them and get rid of the
>> annoying
>> warnings? Googlling on the internet seems no useful results. Some one
>> shield
>> me a light?
>
>
> Does not seem to be a specifiec mod_perl thing, but hey. Have you tried
> "use strict"?
> If that does not do your trick, then elaborate on what you mean by
> 'uninitialized'?
>
> Gr/F
>
>
>
>

Report this message

#7: Re: find all uninitialized variables?

Posted on 2006-02-23 00:50:50 by Tyler MacDonald

Harry Zhu <harry@greatlodge.com> wrote:
> Say I have a file directory with hundreds of modules, I want to know if
> there is a tool I can scan and identify the uninitalized variables in all
> the files once (or through a loop) without actually running through all the
> pages.

If you don't want to run through all the pages and possibilites
yourself, I reccommend selenium:

http://www.openqa.org/selenium/

That will allow you to create test suites that run in your browser
that go through every page and try to do things on it. Then you can check
your error logs and, if your test does everything a regular user possibly
could, you'll have a list of all your uninitialized variables, as well as
possibly turning up some bugs you hadn't tested for before.

There's no easy way to do tell whether or not a variable is going to
be used throughout the course of a webpage, except watching the warnings and
running every single code path that web page has (logged in, not logged in,
filled out this form element before hitting "submit", didn't, etc.)

You might be able to do detect global variables that aren't used by
a package, but nowadays over 90% of variables are local (my) variables, and
still... What if the variable isn't initialized in one module, because
another module initializes it?

Devel::Cover can help to see if you're running every single code
path possible in the code you care about; Devel::Trace and Devel::Profile
can help to see exactly what code you're actually running and when.

If you just want to get rid of the warnings and don't care whether
or not the module is using it's variables cleanly, you can add the line

no warnings 'uninitalized';

to each module that you're being annoyed by.

- Tyler

Report this message

#8: Re: find all uninitialized variables?

Posted on 2006-02-23 00:51:50 by Frank Wiles

On Wed, 22 Feb 2006 17:37:05 -0600
"Harry Zhu" <harry@greatlodge.com> wrote:

> Say I have a file directory with hundreds of modules, I want to know
> if there is a tool I can scan and identify the uninitalized variables
> in all the files once (or through a loop) without actually running
> through all the pages.

Not really. In simple situations, you could regex and find some of
them. But you won't find them all. Take for example:

my $var = $self->get_var;

Is $var initialized? Dunno, depends on what the get_var method
does and returns, which depends on whatever it calls, etc. You can't
really tell except at runtime.

But, you can just turn off this particular warning in your code by
doing this:

use warnings;
no warnings qw( uninitialized );

---------------------------------
Frank Wiles <frank@wiles.org>
http://www.wiles.org
---------------------------------

Report this message

#9: Re: find all uninitialized variables?

Posted on 2006-02-23 00:53:19 by jonathan vanasco

if you
use strict ;
use warnings;

any module that you load w/an uninitialized variable will print an error

what i do is as follows:

use warnings & strict in $APP_DIR/etc/startup.pl
include all my modules in $APP_DIR/etc/startup.pl

tail -f $APP_DIR/logs/error.log

sudo /usr/local/apache2/bin/apachectl restart

that will try and include all the modules i listed in startup.pl

if there's an uninitialized value, apache won't start up, and it will
tell me the line.
i fix that, and try to start apache again

if you preload, you don't have to run through the pages - but it
will crash on the first variable


On Feb 22, 2006, at 6:37 PM, Harry Zhu wrote:

> Say I have a file directory with hundreds of modules, I want to
> know if there is a tool I can scan and identify the uninitalized
> variables in all the files once (or through a loop) without
> actually running through all the pages.
>
> Harry

Report this message

#10: Re: find all uninitialized variables?

Posted on 2006-02-23 01:16:04 by jonathan vanasco

a_ you should preload modules into mod_perl already to take advantage
of shared memory

b_ you can automate listing the files using File::Find and some
sprintf magic

====
my @perl_files ;
use File::Find;
find(\&wanted, ( /paths/to/modules ) );
sub wanted
{
my %pathname = map { $_ , 1 } split '/' , $File::Find::name;

# kill the subversion files
return if ( $pathname{'.svn'} );

# only pm
return unless ( substr( $_ , -5 ) eq '.pm' );

push @ perl_files , $File::Find::name;
}
===




On Feb 22, 2006, at 9:10 PM, <harry@greatlodge.com> wrote:

> Looks like what I needed (if works) but with a lot of editting: use
> Module1,
> use Module2, ..., use ModuleN.
>
>
> Thanks.
>
> Harry
>
>
>
>
> ----- Original Message -----
> From: "Jonathan Vanasco" <jon@2xlp.com>
> To: "Harry Zhu" <harry@greatlodge.com>
> Cc: "mod_perl List" <modperl@perl.apache.org>
> Sent: Wednesday, February 22, 2006 3:53 PM
> Subject: Re: find all uninitialized variables?
>
>
>> if you
>> use strict ;
>> use warnings;
>>
>> any module that you load w/an uninitialized variable will print an
>> error
>>
>> what i do is as follows:
>>
>> use warnings & strict in $APP_DIR/etc/startup.pl
>> include all my modules in $APP_DIR/etc/startup.pl
>>
>> tail -f $APP_DIR/logs/error.log
>>
>> sudo /usr/local/apache2/bin/apachectl restart
>>
>> that will try and include all the modules i listed in startup.pl
>>
>> if there's an uninitialized value, apache won't start up, and it will
>> tell me the line.
>> i fix that, and try to start apache again
>>
>> if you preload, you don't have to run through the pages - but it
>> will crash on the first variable
>>
>>
>> On Feb 22, 2006, at 6:37 PM, Harry Zhu wrote:
>>
>>> Say I have a file directory with hundreds of modules, I want to
>>> know if there is a tool I can scan and identify the uninitalized
>>> variables in all the files once (or through a loop) without
>>> actually running through all the pages.
>>>
>>> Harry
>>
>>
>
>

Report this message

#11: Re: find all uninitialized variables?

Posted on 2006-02-23 01:47:13 by Harry Zhu

Thanks. But I did a simple "svn list -R" and get what I want into a file and
some quick substitution editting. Now I have a test.pl file to load it in
Apach conf.

Harry

----- Original Message -----
From: "Jonathan Vanasco" <jon@2xlp.com>
To: "Harry Zhu" <harry@greatlodge.com>
Cc: "mod_perl List" <modperl@perl.apache.org>
Sent: Wednesday, February 22, 2006 6:16 PM
Subject: Re: find all uninitialized variables?


>
> a_ you should preload modules into mod_perl already to take advantage of
> shared memory
>
> b_ you can automate listing the files using File::Find and some sprintf
> magic
>
> ====
> my @perl_files ;
> use File::Find;
> find(\&wanted, ( /paths/to/modules ) );
> sub wanted
> {
> my %pathname = map { $_ , 1 } split '/' , $File::Find::name;
>
> # kill the subversion files
> return if ( $pathname{'.svn'} );
>
> # only pm
> return unless ( substr( $_ , -5 ) eq '.pm' );
>
> push @ perl_files , $File::Find::name;
> }
> ===
>
>
>
>
> On Feb 22, 2006, at 9:10 PM, <harry@greatlodge.com> wrote:
>
>> Looks like what I needed (if works) but with a lot of editting: use
>> Module1,
>> use Module2, ..., use ModuleN.
>>
>>
>> Thanks.
>>
>> Harry
>>
>>
>>
>>
>> ----- Original Message -----
>> From: "Jonathan Vanasco" <jon@2xlp.com>
>> To: "Harry Zhu" <harry@greatlodge.com>
>> Cc: "mod_perl List" <modperl@perl.apache.org>
>> Sent: Wednesday, February 22, 2006 3:53 PM
>> Subject: Re: find all uninitialized variables?
>>
>>
>>> if you
>>> use strict ;
>>> use warnings;
>>>
>>> any module that you load w/an uninitialized variable will print an
>>> error
>>>
>>> what i do is as follows:
>>>
>>> use warnings & strict in $APP_DIR/etc/startup.pl
>>> include all my modules in $APP_DIR/etc/startup.pl
>>>
>>> tail -f $APP_DIR/logs/error.log
>>>
>>> sudo /usr/local/apache2/bin/apachectl restart
>>>
>>> that will try and include all the modules i listed in startup.pl
>>>
>>> if there's an uninitialized value, apache won't start up, and it will
>>> tell me the line.
>>> i fix that, and try to start apache again
>>>
>>> if you preload, you don't have to run through the pages - but it
>>> will crash on the first variable
>>>
>>>
>>> On Feb 22, 2006, at 6:37 PM, Harry Zhu wrote:
>>>
>>>> Say I have a file directory with hundreds of modules, I want to
>>>> know if there is a tool I can scan and identify the uninitalized
>>>> variables in all the files once (or through a loop) without
>>>> actually running through all the pages.
>>>>
>>>> Harry
>>>
>>>
>>
>>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 268.0.0/266 - Release Date: 2/21/2006
>
>

Report this message

#12: Re: find all uninitialized variables?

Posted on 2006-02-23 03:10:42 by Harry Zhu

Looks like a cool QA tool, I'll check it out.
Thanks.

Harry

----- Original Message -----
From: "Tyler MacDonald" <tyler@yi.org>
To: "Harry Zhu" <harry@greatlodge.com>
Cc: <modperl@perl.apache.org>
Sent: Wednesday, February 22, 2006 3:50 PM
Subject: Re: find all uninitialized variables?


> Harry Zhu <harry@greatlodge.com> wrote:
> > Say I have a file directory with hundreds of modules, I want to know if
> > there is a tool I can scan and identify the uninitalized variables in
all
> > the files once (or through a loop) without actually running through all
the
> > pages.
>
> If you don't want to run through all the pages and possibilites
> yourself, I reccommend selenium:
>
> http://www.openqa.org/selenium/
>
> That will allow you to create test suites that run in your browser
> that go through every page and try to do things on it. Then you can check
> your error logs and, if your test does everything a regular user possibly
> could, you'll have a list of all your uninitialized variables, as well as
> possibly turning up some bugs you hadn't tested for before.
>
> There's no easy way to do tell whether or not a variable is going to
> be used throughout the course of a webpage, except watching the warnings
and
> running every single code path that web page has (logged in, not logged
in,
> filled out this form element before hitting "submit", didn't, etc.)
>
> You might be able to do detect global variables that aren't used by
> a package, but nowadays over 90% of variables are local (my) variables,
and
> still... What if the variable isn't initialized in one module, because
> another module initializes it?
>
> Devel::Cover can help to see if you're running every single code
> path possible in the code you care about; Devel::Trace and Devel::Profile
> can help to see exactly what code you're actually running and when.
>
> If you just want to get rid of the warnings and don't care whether
> or not the module is using it's variables cleanly, you can add the line
>
> no warnings 'uninitalized';
>
> to each module that you're being annoyed by.
>
> - Tyler
>
>
>

Report this message

#13: Re: find all uninitialized variables?

Posted on 2006-02-23 03:10:59 by Harry Zhu

Looks like what I needed (if works) but with a lot of editting: use Module1,
use Module2, ..., use ModuleN.


Thanks.

Harry




----- Original Message -----
From: "Jonathan Vanasco" <jon@2xlp.com>
To: "Harry Zhu" <harry@greatlodge.com>
Cc: "mod_perl List" <modperl@perl.apache.org>
Sent: Wednesday, February 22, 2006 3:53 PM
Subject: Re: find all uninitialized variables?


> if you
> use strict ;
> use warnings;
>
> any module that you load w/an uninitialized variable will print an error
>
> what i do is as follows:
>
> use warnings & strict in $APP_DIR/etc/startup.pl
> include all my modules in $APP_DIR/etc/startup.pl
>
> tail -f $APP_DIR/logs/error.log
>
> sudo /usr/local/apache2/bin/apachectl restart
>
> that will try and include all the modules i listed in startup.pl
>
> if there's an uninitialized value, apache won't start up, and it will
> tell me the line.
> i fix that, and try to start apache again
>
> if you preload, you don't have to run through the pages - but it
> will crash on the first variable
>
>
> On Feb 22, 2006, at 6:37 PM, Harry Zhu wrote:
>
> > Say I have a file directory with hundreds of modules, I want to
> > know if there is a tool I can scan and identify the uninitalized
> > variables in all the files once (or through a loop) without
> > actually running through all the pages.
> >
> > Harry
>
>

Report this message

#14: Re: find all uninitialized variables?

Posted on 2006-02-23 04:52:31 by Ronald J Kimball

On Wed, Feb 22, 2006 at 03:47:45PM -0800, Ryan Gies wrote:
> I've been frustrated with the "Use of uninitialized value" warning
> myself, and was hoping someone could shed some light on it as well.
> Point being, this will issue the warning:
>
> #!/usr/bin/perl -Tw
> sub max { return $_[0] > $_[1] ? $_[0] : $_[1]; }
> max();
>
> In what seems like logic, the undef value should behave like zero or
> empty string when using operators like: '.' ',' 'eq' 'lt' '>' etc...

The undef value *does* behave like zero or the empty string, as
appropriate. That's why you get a valid result, rather than an error or
undefined behavior. Nonetheless, it is uninitialized, so you also get a
warning.

Ronald

Report this message

#15: Re: find all uninitialized variables?

Posted on 2006-02-24 12:12:00 by Konstantin Khomoutov

On Wed, Feb 22, 2006 at 06:10:59PM -0800, harry@greatlodge.com wrote:

> Looks like what I needed (if works) but with a lot of editting: use Module1,
> use Module2, ..., use ModuleN.
Why not just
$ find . -type f -name '*.pl' -print \
-exec perl -Mstrict -Mwarnings -c '{}' \; 2>&1 >error.log?

(Sorry, I'm on Windows now I can't check this, but you've got the
idea.)

Report this message