jptxs has asked for the wisdom of the Perl Monks concerning the following question:
What i want to do is comment up a version of my Perl BIGTIME for my co-worker to take over it, but not use the commented version in the actual cgi directory where it will be executed - no problem for Perl, this would be text parsing. Up til now, whenever I move the file from where I work on it into the production directory, I run it through a script which find all of my dienice calls, dienice being a sub i wrote to output errors to the browser for ease of debugging ("so what does it say on your screen mister user?" he asked on his cell phone.) and numbers them with the current line number from the file being read using $.. so scripts go from:
to# hey I'm a comment open(file, "wibbywoo") or dienice("some bloated error message");
Now, however, I'll be strippng the comments first, /!^#/, and then outputing the file. So output will no longer come from a file, where I have $. to tell me the line number rather from an array of comment stripped lines.# hey I'm a comment open(file, "wibbywoo") or dienice("Line 2: some bloated error message" +);
The Question: aside from
is there a better way? I looked through perlvar for some sort of 'array index' var for the current lexically relavant @_, but nothing seems to do the trick. Admittedly, perlvar has been known to make my philosoper's eyes bleed spontaneously from time to time, so I want to be sure I'm not missing something.my $counter = "0"; for (@stripped_array) { $_ =~ s/dienice\(\"/dienice\(\"Line $counter/; + $counter++; }
"sometimes when you make a request for the head you don't
want the big, fat body...don't you go snickering."
-- Nathan Torkington UoP2K a.k.a gnat
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: current array index
by Adam (Vicar) on Nov 03, 2000 at 23:53 UTC | |
by jptxs (Curate) on Nov 04, 2000 at 00:01 UTC | |
by tye (Sage) on Nov 04, 2000 at 00:26 UTC | |
by Adam (Vicar) on Nov 04, 2000 at 00:37 UTC | |
by jptxs (Curate) on Nov 04, 2000 at 06:27 UTC | |
|
RE: current array index
by AgentM (Curate) on Nov 04, 2000 at 01:01 UTC | |
by jptxs (Curate) on Nov 04, 2000 at 06:30 UTC | |
|
RE: current array index
by extremely (Priest) on Nov 04, 2000 at 12:34 UTC | |
|
Re: current array index
by chromatic (Archbishop) on Nov 04, 2000 at 00:21 UTC |