HELP: Innocuous return stmt yields errors 
Author Message
 HELP: Innocuous return stmt yields errors

sub count_spikes {
    my ($spike_ct,$i);
    $spike_ct = 0;
    for ($i=0; $i< nelem($Persync::current_piddle); ++$i) {
        if spike_at($i) {
            ++$spike_ct;
        }
    }
    return($spike_ct);

Quote:
}

yields the following errs:

 DB<2> use Persync
Global symbol "spike_ct" requires explicit package name at /felix/terry/scripts/perl/Persync.pm line 204, <IN> chunk 2.
        require Persync.pm called at (eval 5) line 2
        main::BEGIN called at /felix/terry/scripts/perl/Persync.pm line 204
        eval {...} called at /felix/terry/scripts/perl/Persync.pm line 204

use Persync;

;' called at /usr/lib/perl5/perl5db.pl line 926
        DB::eval called at /usr/lib/perl5/perl5db.pl line 848
        DB::DB called at -e line 1
syntax error at /felix/terry/scripts/perl/Persync.pm line 205, near "}"
BEGIN failed--compilation aborted at (eval 5) line 2, <IN> chunk 2.

  DB<3>
--
o============o  Sending unsolicited commercial e-mail (UCE)  to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.



Sat, 08 Jan 2000 03:00:00 GMT  
 HELP: Innocuous return stmt yields errors


Quote:
>    if spike_at($i) {

Oops. The conditional in an 'if' statement must be parenthesized. Not that
that has anything to do with your return statement... :-)  (I suspect that
there's some of your program that you're not showing us, and that that
part has the real errors.) Hope this helps!

--
Tom Phoenix           http://www.teleport.com/~rootbeer/

Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



Sat, 08 Jan 2000 03:00:00 GMT  
 HELP: Innocuous return stmt yields errors

Quote:

>sub count_spikes {
>    my ($spike_ct,$i);
>    $spike_ct = 0;
>    for ($i=0; $i< nelem($Persync::current_piddle); ++$i) {
>    if spike_at($i) {
>        ++$spike_ct;
>    }
>    }
>    return($spike_ct);
>}

>yields the following errs:

> DB<2> use Persync
>Global symbol "spike_ct" requires explicit package name at /felix/terry/scripts/perl/Persync.pm line 204, <IN> chunk 2.

 [snip]

When I run that, I get errors

syntax error at - line 6, near "if spike_at"
Global symbol "spike_ct" requires explicit package name at - line 10.

The first error is because that "if" should read

        if (spike_at($i)) {

After syntax errors involving incorrect brackets, Perl tends to get
confused about scopes of lexicals, not entirely surprisingly.   This is
the cause of the second error.

In cases like this, if you can explain some but not all of your compiler
errors, fix the ones you understand and try again.

Mike Guy



Mon, 10 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DBI prepare error when running select stmt

2. Statistics::Descriptive yields error in AUTOLOAD

3. Statistics::Descriptive yields error in AUTOLOAD

4. HELP ODBC sql stmt failing when using WHERE LIKE

5. Return does not return error codes

6. Help: carriage return errors

7. In search of elegant code - running code within a larger Print stmt

8. How to continue long stmt on next line?

9. Unexecuted stmt adds array elem??

10. I would like for a field to be variable width in a format stmt

11. Why is this if stmt matching every file?

12. why no case stmt

 

 
Powered by phpBB® Forum Software