Home > Archive > PERL Beginners > June 2005 > perl question - unused variables
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
perl question - unused variables
|
|
| Troy S 2005-06-08, 8:56 pm |
| How can i automatically detect unused variables in Perl?
i delcrae variables like:
my $abc;
but don't use $abc within the subroutine.
how can i get perl to autmatically tell me that $abc is not being used
(other than the declaration)????
evhorig
---------------------------------
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
| |
| Bob Showalter 2005-06-08, 8:56 pm |
| Troy S wrote:
> How can i automatically detect unused variables in Perl?
>
> i delcrae variables like:
> my $abc;
>
> but don't use $abc within the subroutine.
>
> how can i get perl to autmatically tell me that $abc is not being used
> (other than the declaration)????
Possibly use the output of B::Xref to look for variables with only an
introduction ("i")?
perldoc B::Xref
| |
| Ryan Frantz 2005-06-08, 8:56 pm |
| I'm (very) new to Perl but I thought there was an easier way to do this.
I use the '-w' switch when specifying my interpreter at the beginning of
my script:
#!/usr/bin/perl -w
and it always tells me if I have a declared variable that doesn't get
used.
ry
-----Original Message-----
From: Bob Showalter [mailto:Bob_Showalter@taylorwhite.com]=20
Sent: Wednesday, June 08, 2005 2:52 PM
To: 'Troy S'; beginners@perl.org
Subject: RE: perl question - unused variables
Troy S wrote:
> How can i automatically detect unused variables in Perl?
>=20
> i delcrae variables like:
> my $abc;
>=20
> but don't use $abc within the subroutine.
>=20
> how can i get perl to autmatically tell me that $abc is not being used
> (other than the declaration)????
Possibly use the output of B::Xref to look for variables with only an
introduction ("i")?
perldoc B::Xref
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Wagner, David --- Senior Programmer Analyst --- WG 2005-06-08, 8:56 pm |
| Ryan Frantz wrote:
> I'm (very) new to Perl but I thought there was an easier way to do
> this. I use the '-w' switch when specifying my interpreter at the
> beginning of my script:
>=20
> #!/usr/bin/perl -w
>=20
> and it always tells me if I have a declared variable that doesn't get
> used.
>=20
> ry
You are not using strict because if so then declaring say my $abc; and usi=
ng strict and -w, I do not get any warning. Hopefully one of Perl gurus ca=
n enlighten us.
Wags ;)
>=20
> -----Original Message-----
> From: Bob Showalter [mailto:Bob_Showalter@taylorwhite.com]
> Sent: Wednesday, June 08, 2005 2:52 PM
> To: 'Troy S'; beginners@perl.org
> Subject: RE: perl question - unused variables
>=20
> Troy S wrote:
>=20
> Possibly use the output of B::Xref to look for variables with only an
> introduction ("i")?
>=20
> perldoc B::Xref
>=20
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
****************************************
***************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************
***************
| |
| Ryan Frantz 2005-06-08, 8:56 pm |
| You're right; I'm not using 'use strict;' at the moment. But if I
declare a variable called '$nothing' in a script on working on now, I
get:
Useless use of a variable in void context at mail_test line 11.
Name "main::nothing" used only once: possible typo at mail_test line
11.
If I use 'use strict;' I get a flurry of other messages ;).
my $perl_experience =3D n00b
-----Original Message-----
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:David.Wagner@freight.fedex.com]=20
Sent: Wednesday, June 08, 2005 3:21 PM
To: Ryan Frantz; Troy S; beginners@perl.org
Subject: RE: perl question - unused variables
Ryan Frantz wrote:
> I'm (very) new to Perl but I thought there was an easier way to do
> this. I use the '-w' switch when specifying my interpreter at the
> beginning of my script:
>=20
> #!/usr/bin/perl -w
>=20
> and it always tells me if I have a declared variable that doesn't get
> used.
>=20
> ry
You are not using strict because if so then declaring say my
$abc; and using strict and -w, I do not get any warning. Hopefully one
of Perl gurus can enlighten us.
Wags ;)
>=20
> -----Original Message-----
> From: Bob Showalter [mailto:Bob_Showalter@taylorwhite.com]
> Sent: Wednesday, June 08, 2005 2:52 PM
> To: 'Troy S'; beginners@perl.org
> Subject: RE: perl question - unused variables
>=20
> Troy S wrote:
>=20
> Possibly use the output of B::Xref to look for variables with only an
> introduction ("i")?
>=20
> perldoc B::Xref
>=20
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
****************************************
***************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************
***************
|
|
|
|
|