in reply to Re: newbie regex question: substituting repeating occurences for different replacements
in thread newbie regex question: substituting repeating occurences for different replacements

Or in a pinch,
while(<DATA>) { my $i; chomp; print join('', map { $i++; "<col$i>$_</col$i>" }, split /;/)."\n"; } __ hello;this;is;a;test this;is;another;simple;test

Makeshifts last the longest.

  • Comment on Re^2: newbie regex question: substituting repeating occurences for different replacements
  • Download Code

Replies are listed 'Best First'.
Re: Re^2: newbie regex question: substituting repeating occurences for different replacements
by eric256 (Parson) on Jul 23, 2003 at 17:56 UTC

    Cool. I always have a hard time figureing out when/how to use map. The more i see it the more it makes sense though. I think its partly because i'm not used to magical vars like $_ yet.

    Eric Hodges
      Well yes, avoiding $_ won't get you very far with map. :)

      Makeshifts last the longest.