come to think of it. This "newline" I am getting must be a result of
windows just dropping my prompt to the next line. So I assumed it was
there...
Stupid me. I am used to Linux which does not do this in the shell.

Ok then this brings me full circle.
When I run this program on UNIX it makes an excel spread sheet that has
little square strange characters at the end of every row in the last
cell.
I assumed they where new lines but I have ruled this out as I am not
printing any new lines. Any idea on how to fix this? It works in windows
but not on my sco box.

#!/usr/bin/perl

open IPO,('ipo.txt');
$count=2;
$lineref=['PEL Supply Company - IPO Price List',
          ['Item Code','Description','List','Vendor']];
$addline = sub {$worksheet->write_row($count,0,$lineref)};

#setup excel spread sheet
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
$worksheet   = $workbook->addworksheet();
$format1  = $workbook->addformat();
$format2  = $workbook->addformat();
$format3  = $workbook->addformat();
$format4  = $workbook->addformat();

#Format 1 (Header Row: Bold, BG Yellow, Bottom Border)
$format1->set_bold();
$format1->set_bg_color('yellow');
$format1->set_bottom();

#Format 2 (List Column Right justified set to currency)
$format2->set_align('right');
$format2->set_num_format(8);

#Format 3 (List Column Header - Bold, Yel BG, Bottom Border, Right
Justified)
$format3->set_bold();
$format3->set_bg_color('yellow');
$format3->set_bottom();
$format3->set_align('right');

#Format 4
$format4->set_bold();
$format4->set_bg_color('yellow');
$format4->set_merge();


#Format Columns
$worksheet->set_column(0,0, 25);
$worksheet->set_column(1,1, 44);
$worksheet->set_column(2,2, 10,$format2);
$worksheet->set_column(3,3, 15);
$worksheet->freeze_panes(2,0);

#Write Header Row
$worksheet->write(0,0,$lineref->[0],$format4);
$worksheet->write_blank(0,1,$format4);
$worksheet->write_blank(0,2,$format4);
$worksheet->write_blank(0,3,$format4);

$worksheet->write(1,0,$lineref->[1]->[0],$format1);    # Item Code
$worksheet->write(1,1,$lineref->[1]->[1],$format1);    # Item
Description
$worksheet->write(1,2,$lineref->[1]->[2],$format3);    # Item List
$worksheet->write(1,3,$lineref->[1]->[3],$format1);    # Vendor Code

$lineref = \@line;

while (<IPO>){
    chomp;
    @line=split /\|/,$_;
    $line[2]=~s/ //g;
    &$addline;
    $count++;
}


> -----Original Message-----
> From: Dan Muey [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 16, 2003 10:49 AM
> To: Paul Kraus; Perl
> Subject: RE: Where is the new line coming from.
>
>
> > I am reading in a text file that has input similar to this.
> > date|data|data|data\n
> >
> > I then read the file in and using a while loop I chomp off
> > the new line. while (<IPO>){
> >     chomp;
> >     @line=split /\|/,$_;
> >     $line[2]=~s/ //g;
>
> Do you mean $line[3] since that is the last one in the array
> in the example above?
> date1|data2|data3|data4\n would become
> 0 data1
> 1 data2
> 2 data3
> 3 data4\n
> If so remove any newlines and space also :
> $line[3] =~ s/\n|\r| //g;
> Or use '\s' instead of ' ' for the space.
>
> Dan
> >     print "$_" foreach (@line);
> >     last;
> >     $count++;
> >     last if ($count == 7);
> > }
> >
> > Here is the mystery. the output has a newline at the end of
> > it. It should print
> > "data data data data" and then my next prompt should be right
> > here. instead it prints
> > "data data data data
> > "and my prompt is here.
> >
> > If I remove the initial chomp then I get a double space at the end.
> >
> > No matter what I print the last element gets a new line ?????
> >
> > Example if I
> >     print "$line[0] $line[1]";
> > then right at the end of the print statement is a new line
> > and the output is identical to what I previously described.
> > the last elements always inherits a new line. It driving me
> > crazy!!! thanks in advance :)
> >    
> >
> > Paul Kraus
> > Network Administrator
> > PEL Supply Company
> > 216.267.5775 Voice
> > 216-267-6176 Fax
> > www.pelsupply.com
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to