in reply to inserting array of data into text file

Add an e to the end of the regex in the second while loop.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: inserting array of data into text file

Replies are listed 'Best First'.
Re^2: inserting array of data into text file
by Anonymous Monk on Jul 13, 2004 at 13:29 UTC
    \e as in esc? $_ =~ s/^(\S\s+\S)/$1 $col$i++\e/; not difference in where it stops
      s/^(\S\s+\S)/$1 $col[$i++]/e; - you have code you need executed in the replacement half of the substitution. Perl doesn't do that unless you tell it to.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

        Wrong. He wants it as a string, so it shouldn't have an /e. Quite the contrary, adding an /e would make his syntax invalid. You didn't even test your code, did you?

        The only code I see is in the array index, and code in array or hash indexes is always executed, if the variable will be interpolated — thus: in double-quotish context. That's how the module Interpolation works.

      meant following not subs e! $_ =~ s/^(\S\s+\S)/$1 $coli++/\e;
        with  $_ =~ s/^(\S\s+\S)/$1, $col[$i++]/e; stops in the same place? does this point to a key problem?