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
In reply to current array index by jptxs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |