On Wed, 4 Feb 2004, Jeff 'japhy' Pinyan wrote:

<snip>
> >
> >  foreach $i (@grok) {
> >   chomp($i);
> >
> >($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp)
> >= split(/\|/,$i);
> >   print FILE
> >"$inv|$item_num|$item_desc|$b1|$b2|$b3|$b4|$cc|$vn|$qoh|$qc|$qor|$bc|$it
> >em_num|$sc|$yp\n";
> >   $inv++;
> > }
> 
> Oh good God.  Do you know what that for loop is DOING?
> 
>   for each element in @grok:
>     remove the newline
>     split it on pipes into some variables
>     print $inv, those variables with pipes in between, and add a newline
> 
> That is terribly insane.

Jeff, The input and output lines are not identical. The output line
prefixes $inv at the front and inserts $item_num between $bc and $sc. I
don't know why $item_num is repeated. Granted that I think a more
efficient construct might be:

my ($item_num,$a,$b) = $i =~ /(.*?|)((?:.*?|){11})(.*)/;
print LINE "$inv|$item_num|$a|$item_num|$b\n";

I think that I have that right. Well, assuming that the original is 
correct.


--
Maranatha!
John McKown


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to