Problems? Is your data what you think it is? | |
PerlMonks |
loop executionby staeryatz (Monk) |
on Oct 25, 2001 at 00:55 UTC ( [id://121270]=perlquestion: print w/replies, xml ) | Need Help?? |
staeryatz has asked for the wisdom of the Perl Monks concerning the following question:
I seek enlightenment, my Perl brothers... I'm re-writing a program of mine, originally made in C++, thinking the best way to learn Perl is to write programs with it, and see how it differs from the other languages. My program parses source code to generate HTML files with highlighting. I'm trying to make a CGI version of it now. Here's my problem: I'm running a foreach loop for an array, and the block of code inside the loop contains regex's. Each of the regex's only get executed once for the whole array, instead of being executed for each array cell. I've tried just a regular for loop, and I still get the same thing. Here's a similar code snippet:
If the @code array contained (each line being an array cell): this "that" this "and" that "and" this "and" that The output would be: this "that" this "and" that "and" this "and" that But, what the output should be (or what I'm hoping for) is: this "that" this "and" that "and" this "and" that Can somebody show me why the regex only gets executed once, (for only the first appearance of the expression), and not for every time through the loop? Any help would be greatly appreciated. BTW: I'm using Perl 5.6.1 on a Linux box, and also: Perl is a very sexy language. ;) Edit Masem - Code Tags
Back to
Seekers of Perl Wisdom
|
|