Link to home
Start Free TrialLog in
Avatar of bebosoft
bebosoft

asked on

How can I break a loop in Perl if using 'use strict'?

I've a Perl script working perfectly and now I must add:

use strict;

at the beginning of the script in order to run it correctly in a new server.

I get an error:

Bareword "break" not allowed while "strict subs" in use at form_all_perl.pl line 137

I'm using the 'break' statement to exit a loop and it was working fine until I added the 'use strict'.

What does that error means? How can I exit a loop when using 'use strict'?
ASKER CERTIFIED SOLUTION
Avatar of easyvbapps
easyvbapps

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bebosoft
bebosoft

ASKER

I'm curious why the 'break' statements works in Perl scripts if not using the 'use strict' command.
Can you please provide an example of a Perl script where break "works"?
If the script really was working perfectly, then you can use "break" in quotes to mean the same thing that the bareword break means under no strict subs


splain
/usr/bin/splain: Reading from STDIN
Bareword "break" not allowed while "strict subs" in use at form_all_perl.pl line 137
Bareword "break" not allowed while "strict subs" in use at form_all_perl.pl
        line 137 (#1)
    (F) With "strict subs" in use, a bareword is only allowed as a
    subroutine identifier, in curly brackets or to the left of the "=>"
    symbol.  Perhaps you need to predeclare a subroutine?