<html><div style='background-color:'><DIV class=RTE>
<P>Amen to Jeff's comments to say nothing of the code sample!</P>
<P>jvs<BR><BR></P></DIV>
<DIV></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #a0c6e5 2px solid; MARGIN-RIGHT: 0px"><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">
<HR color=#a0c6e5 SIZE=1>

<DIV></DIV>From:&nbsp;&nbsp;<I>Jeff Stampes &lt;jeff.stampes@xilinx.com&gt;</I><BR>Reply-To:&nbsp;&nbsp;<I>boulder-pm@pm.org</I><BR>To:&nbsp;&nbsp;<I>boulder-pm@pm.org</I><BR>Subject:&nbsp;&nbsp;<I>Re: [Boulder.pm] Newbie File Manipulation question</I><BR>Date:&nbsp;&nbsp;<I>Mon, 17 Jul 2006 11:43:21 -0600</I><BR>Rod Burgess wrote:<BR>&gt; I am new to the Perl world and am trying to learn it.&nbsp;&nbsp;A coworker tells me<BR>&gt; that Perl will not work for what I am trying to do<BR>Hopefully your coworker has other fields of expertise that they *are*<BR>qualified to address.<BR>&gt;&nbsp;&nbsp;however, I think Perl<BR>&gt; would be a great tool to use and&nbsp;&nbsp;I feel this coworker is wrong.<BR>&gt;<BR>You are correct.&nbsp;&nbsp;In fact, the stunning thing about your coworker's<BR>comments is that this sort of work is what perl excels at!<BR>&gt; I have a file that contains 
several lines all as below:<BR>&gt; DR03555{tab}&nbsp;&nbsp;&nbsp;&nbsp;45600062888{tab}&nbsp;&nbsp;&nbsp;&nbsp; 00008FLAT WASHER<BR>&gt; DR03555{tab}&nbsp;&nbsp;&nbsp;&nbsp;228765329{tab}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00001GASKET<BR>&gt;<BR>&gt; The meaning of the file is<BR>&gt; DR03555 = order number<BR>&gt; 45600062888 = part number<BR>&gt; 00008 = quantity<BR>&gt; FLAT WASHER = Description<BR>&gt;<BR>&gt; The lines all begin with the prefex DR&nbsp;&nbsp;I would like to read this file and<BR>&gt; produce the following output:<BR>&gt;<BR>&gt; 45600062888;8;FLAT WASHER<BR>&gt; 228765329;1;GASKET<BR>&gt;<BR>&gt; basiclly I need a file that lists the following:&nbsp;&nbsp;Part#;Quantity;Description<BR>&gt;<BR>&gt; Is this possible with Perl?<BR>&gt;<BR>In many, many ways!&nbsp;&nbsp;Here's one:<BR><BR>#!/usr/bin/perl<BR><BR>use warnings;<BR>use strict;<BR><BR>while ( my 
$orderData = &lt;DATA&gt; ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;chomp $orderData;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;my ($quantity, $description );<BR>&nbsp;&nbsp;&nbsp;&nbsp;my ($orderNumber, $partNumber, $other ) = split /\t/, $orderData;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;if ( $other =~ /^(\d{5})(.+)$/ ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ($quantity, $description) = ( $1, $2 );<BR>&nbsp;&nbsp;&nbsp;&nbsp;} else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; die "Bad quantity/description data found\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;print "$partNumber;$quantity;$description\n";<BR>}<BR><BR>__DATA__<BR>DR03555&nbsp;&nbsp;&nbsp;&nbsp;45600062888&nbsp;&nbsp;&nbsp;&nbsp;00008FLAT WASHER<BR>DR03555&nbsp;&nbsp;&nbsp;&nbsp;228765329&nbsp;&nbsp;&nbsp;&nbsp;00001GASKET<BR><BR><BR>_______________________________________________<BR>Boulder-pm mailing 
list<BR>Boulder-pm@pm.org<BR>http://mail.pm.org/mailman/listinfo/boulder-pm<BR></FONT></BLOCKQUOTE></div><br clear=all><hr> <a href="http://g.msn.com/8HMAENUS/2728??PS=47575" target="_top">Check the weather anywhere, anytime - just type "weather" from MSN Search </a> </html>