in reply to Re: inserting array of data into text file
in thread inserting array of data into text file

\e as in esc? $_ =~ s/^(\S\s+\S)/$1 $col$i++\e/; not difference in where it stops
  • Comment on Re^2: inserting array of data into text file

Replies are listed 'Best First'.
Re^3: inserting array of data into text file
by dragonchild (Archbishop) on Jul 13, 2004 at 13:45 UTC
    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.

        I think people get confused because of the /e being optional if there's just one thing there (e.g. s/(\S+)/$translate{$1}/e; is equivalent to s/(\S+)/$translate{$1}/;).
Re^3: inserting array of data into text file
by Anonymous Monk on Jul 13, 2004 at 13:45 UTC
    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?
        Without seeing the rest of your code, I can provide no further help.

        ------
        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