<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Ahhh... in that case, I'd think you really want a split-map-join
construct like so:<br>
<blockquote><tt>foreach my $piece (@pieces) {<br>
&nbsp;&nbsp;&nbsp; $cnt = 6;<br>
&nbsp;&nbsp;&nbsp; print join("\t", map { ($cnt-- &gt; 0) ? "\"$_\"" : $_ }
split(/\t/, $piece)), "\n";;<br>
}</tt><br>
</blockquote>
Tim.<br>
<br>
Barron Snyder (CE CEN) wrote:
<blockquote
 cite="mid28CEB74C14F56548BC3F1504129E99F50149D266@wfm-exchprd5.wfm.pvt"
 type="cite">
  <pre wrap="">Here is some sample data (input):
FL        999-NO_SUBTEAM        Actuals        ASSETS        FY2006        6        19,416.86
FL        DP-999        Actuals        150000        FY2006        6        19,416.86
FL        DP-999        Actuals        WIP        FY2006        6        19,416.86
FL        DP-999        Actuals        TOT_PPE        FY2006        6        19,416.86
FL        DP-999        Actuals        LT_ASSET        FY2006        6        19,416.86
FL        DP-999        Actuals        ASSETS        FY2006        6        19,416.86
FL        NON_MARGIN        Actuals        510000        FY2006        6        11,866.97
FL        NON_MARGIN        Actuals        SUPP_PKG        FY2006        6
11,866.97

And here is what it should end up like (output):
"FL"        "999-NO_SUBTEAM"        "Actuals"        "ASSETS"        "FY2006"
"6"        19,416.86
"FL"        "DP-999"        "Actuals"        "150000"        "FY2006"
"6"        19,416.86
"FL"        "DP-999"        "Actuals"        "WIP"        "FY2006"        "6"
19,416.86
"FL"        "DP-999"        "Actuals"        "TOT_PPE"        "FY2006"
"6"        19,416.86
"FL"        "DP-999"        "Actuals"        "LT_ASSET"        "FY2006"
"6"        19,416.86
"FL"        "DP-999"        "Actuals"        "ASSETS"        "FY2006"
"6"        19,416.86
"FL"        "NON_MARGIN"        "Actuals"        "510000"        "FY2006"
"6"        11,866.97
"FL"        "NON_MARGIN"        "Actuals"        "SUPP_PKG"        "FY2006"
"6"        11,866.97

All values except those in the final column should be wrapped in
double-quotes and tabs should separate the values.

My solution does it like this:
...
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";
}
...

But as I mentioned, in my effort to learn more about Perl, I thout there
may be a more elegant way using regular expressions.

Thanks,
            
Barron Snyder

-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:austin-bounces+barron.snyder=wholefoods.com@pm.org">austin-bounces+barron.snyder=wholefoods.com@pm.org</a>
[<a class="moz-txt-link-freetext" href="mailto:austin-bounces+barron.snyder=wholefoods.com@pm.org">mailto:austin-bounces+barron.snyder=wholefoods.com@pm.org</a>] On Behalf Of
Zach Vonler
Sent: Wednesday, August 16, 2006 10:42 AM
To: <a class="moz-txt-link-abbreviated" href="mailto:austin@pm.org">austin@pm.org</a>
Subject: Re: APM: Regular Expression Question

On 8/16/06, Jay Flaherty <a class="moz-txt-link-rfc2396E" href="mailto:jayflaherty@gmail.com">&lt;jayflaherty@gmail.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">$piece =~ s/\t{0,3}/\"\t\"/g;
    </pre>
  </blockquote>
  <pre wrap=""><!---->
There are two problems with this one, the first being that you have
the ability to match on a null string, and the second being that
whatever does get matched is replaced by only a single "\t".

If the number of fields you want to modify is in $count, something like

$repl = "\\\"\\t\\\"" x $count;
$piece =~ s/\t{$count,$count}/$repl/;

might get you most of the way there.  Note of course that it does not
modify inputs with fewer than $count fields.

Later,
Zach
_______________________________________________
Austin mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Austin@pm.org">Austin@pm.org</a>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/austin">http://mail.pm.org/mailman/listinfo/austin</a>
_______________________________________________
Austin mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Austin@pm.org">Austin@pm.org</a>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/austin">http://mail.pm.org/mailman/listinfo/austin</a>

  </pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
 _______________________________________________________________________
                                                      Timothy E. Peoples
                                                   Have Camel, Will Code
                                                         <a class="moz-txt-link-abbreviated" href="mailto:tim@toolman.org">tim@toolman.org</a>

</pre>

<DIV><P><HR>
This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.
</P></DIV>
</body>
</html>