APM: Regular Expression Question

Zach Vonler zvonler at gmail.com
Wed Aug 16 09:10:44 PDT 2006


On 8/16/06, Barron Snyder (CE CEN) <Barron.Snyder at wholefoods.com> wrote:
> foreach my $piece (@pieces) {
>         my @strings = split(/\t/, $piece);
>         print DATA_OUT "\"", join ("\"\t\"", $strings[0], $strings[1],
> $strings[2], $strings[3], $strings[4], $strings[5]), "\"\t",
> $strings[6], "\n";
> }

In that case, I think using regexes makes the problem harder, not
easier.  How about the following instead:

my @strings = split /\t/, $piece;
print DATA_OUT "\"", join("\"\t\"", @strings[0..5]), "\"\t$string[6]\n";

Essentially the same as what you were doing.  Split and join are
highly optimized, so I think they're a win over trying to do this in a
regex.

Later,
Zach


More information about the Austin mailing list