I keep getting bogus messages like:
Name ams::uscs_trailer_out used only once: possible typo at
/local/bax/test/uscs_client.pl line 137.
Name ams::uscs_header_out used only once: possible typo at
/local/bax/test/uscs_client.pl line 137.
even though I have:
package ams;
..
our $SOH =
--- Ranga Nathan mumbled on 2004-06-07 11.49.43 -0700 ---
I keep getting bogus messages like:
Name ams::uscs_trailer_out used only once: possible typo at
/local/bax/test/uscs_client.pl line 137.
Name ams::uscs_header_out used only once: possible typo at
/local/bax/test/uscs_client.pl line
01:09 PM
To: Ranga Nathan [EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
Subject:Re: [Boston.pm] Variable used only once warning
--- Ranga Nathan mumbled on 2004-06-07 11.49.43 -0700 ---
I keep getting bogus messages like:
Name ams::uscs_trailer_out used only
Dear Mike,
To use a variable means to have it on the RHS, usually. LHS only counts
as defining it.
In computer science, yes. In perl (surprise!) no.
--\/BEGIN-\/--
% perl -lwe '$x = hi;'
Name main::x used only once: possible typo at -e
On Mon, 7 Jun 2004, Ranga Nathan wrote:
But why should the compiler care if I used a variable only once?
Because the rest of your program may have $foobar 42 times, but this one
line has $foobaz, and the compiler can't be sure that that's a mistake,
but chances aren't bad that that odd one out
The compiler doesn't but it thinks you do :-)
$grand_total += total1;
$grand_total += total2;
$grand_total += total3;
$grnad_total += total4;
^^^
$grnad_total is used only once and is most likely a tupo.
On 2004.06.07 16:35, Ranga Nathan wrote:
But why should the compiler care if I used a
Dear Chris,
If you define a variable use it only once, the compiler will complain.
No, it won't. At least not the perl compiler.
For perl, an assignment (== definition) is also a use.
=begin repeated_example
--\/BEGIN-\/--
% perl -lwe
RN == Ranga Nathan [EMAIL PROTECTED] writes:
RN I keep getting bogus messages like:
RN Name ams::uscs_trailer_out used only once: possible typo at
RN /local/bax/test/uscs_client.pl line 137.
RN Name ams::uscs_header_out used only once: possible typo at
RN
$grand_total += total1;
$grand_total += total2;
$grand_total += total3;
$grnad_total += total4;
^^^
$grnad_total is used only once and is most likely a tupo.
use strict should complain about that, even without warnings turned on. Assuming
that you never declared $grnad_total, of course.