in reply to Why is my script not printing anything?and how to add a switch case in perl
This is a lovely example of why global variables are a bad idea! By making all your variables global you almost completely obviate the primary reason for using strict. Don't use globals like that!
As toolic observed your rubbishy indenting hides the fact that you have nested your 'main' code inside one of your subroutines. A big comment in the code does nothing at all to fix that!
Keep variables local and pass them around to subroutines if required. Id' provide sample code to show how this could be tidied up, but there's not enough context for me to be sure just what you are parsing and how you really want to handle errors. If you provide more context (a small sample input file and expected output would help) someone might provide a nice example for you to work from.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why is my script not printing anything?and how to add a switch case in perl
by iphone (Beadle) on Dec 02, 2010 at 03:52 UTC | |
by GrandFather (Saint) on Dec 02, 2010 at 04:25 UTC | |
by iphone (Beadle) on Dec 02, 2010 at 05:09 UTC | |
by GrandFather (Saint) on Dec 02, 2010 at 06:03 UTC | |
by iphone (Beadle) on Dec 02, 2010 at 07:23 UTC | |
| |
by pemungkah (Priest) on Dec 02, 2010 at 23:42 UTC |