in reply to Use of uninitialized value in regexp
Hello bbb,
The variable $word is lexically scoped, meaning its scope extends only to the end of the block in which it is declared. Since you declare it in an if block which is itself within a while block, it is out of scope by the time you try to print it.
You need to declare $word before the while loop.1 If you had use strict; at the head of your script, it would highlight this kind of error for you.
1Update: Or move the print statement to within the if block.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use of uninitialized value in regexp
by bbb (Novice) on Feb 10, 2015 at 00:43 UTC | |
by AnomalousMonk (Archbishop) on Feb 10, 2015 at 01:17 UTC | |
by bbb (Novice) on Feb 17, 2015 at 01:12 UTC |