If all you need to do is seperate the array with spaces, you could use the following code snippet:
$" = ' '; print FILE "@array"; The $" variable is the list seperator special variable. This may be faster than doing the join. Troy ----- Original Message ----- From: "Daniel Gross" <[EMAIL PROTECTED]> To: "'Scot Robnett'" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, April 02, 2003 13:58 Subject: RE: Removing all \n in a text file. > Perl is amazing ... Reminds me of lisp where 4-5 of heavily recursive > lines do it all ... Just, thank G-d, its not heavily recursive :-) > > > Thanks > > Daniel > > > -----Original Message----- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:46 PM > To: Daniel Gross > Cc: [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > chomp(@ary); > print FILE join (' ', @ary); > > Scot R. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Daniel Gross > Sent: Wednesday, April 02, 2003 12:45 PM > To: 'Scot Robnett' > Cc: [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > Hi Scott, > > Actually, it turns out that sometimes I need to chomp a \n but also add > a space instead (to not concatenate the strings at the end of one line > with the one in the beginning of the next line. > > Which, I guess rules out the short version :-) > > Thanks > > Daniel > > > -----Original Message----- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:30 PM > To: Carl Jolley > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > See, I told you somebody would follow with a shorter and cleaner > example. > :-) > > Scot R. > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Carl Jolley > Sent: Wednesday, April 02, 2003 12:17 PM > To: Scot Robnett > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > On Mon, 31 Mar 2003, Scot Robnett wrote: > > > That seems like a lot of work when you could just do something like > > what's shown below. And I'm sure someone is going to follow with > > something > shorter > > and cleaner than this one, but it's a start. I did test it and it > > worked. > > > > > > #!C:\Perl\bin\perl.exe -w > > > > use strict; > > my $file = 'C:\path\to\file.txt'; > > my @ary = (); > > > > open(FILE, "<$file"); > > @ary = <FILE>; > > close(FILE); > > > > open(FILE, ">$file"); > > for(@ary) { > > chomp; > > print FILE $_; > > } > > close(FILE); > > > > print "Newlines removed. \n"; > > > > > > > > ############################# > > This was the file before: > > ############################# > > line1 > > line2 > > line3 > > line4 > > line5 > > line6 > > line7 > > line8 > > line9 > > line10 > > > > > > ############################# > > This was the file after: > > ############################# > > line1line2line3line4line5line6line7line8line9line10 > > No need to use a loop to chomp and print each line, instead: > > chomp(@ary); > print FILE @ary; > > **** [EMAIL PROTECTED] <Carl Jolley> > **** All opinions are my own and not necessarily those of my employer > **** > > _______________________________________________ > Perl-Win32-Users mailing list [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > -----Original Message----- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:30 PM > To: Carl Jolley > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > See, I told you somebody would follow with a shorter and cleaner > example. > :-) > > Scot R. > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Carl Jolley > Sent: Wednesday, April 02, 2003 12:17 PM > To: Scot Robnett > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > On Mon, 31 Mar 2003, Scot Robnett wrote: > > > That seems like a lot of work when you could just do something like > > what's shown below. And I'm sure someone is going to follow with > > something > shorter > > and cleaner than this one, but it's a start. I did test it and it > > worked. > > > > > > #!C:\Perl\bin\perl.exe -w > > > > use strict; > > my $file = 'C:\path\to\file.txt'; > > my @ary = (); > > > > open(FILE, "<$file"); > > @ary = <FILE>; > > close(FILE); > > > > open(FILE, ">$file"); > > for(@ary) { > > chomp; > > print FILE $_; > > } > > close(FILE); > > > > print "Newlines removed. \n"; > > > > > > > > ############################# > > This was the file before: > > ############################# > > line1 > > line2 > > line3 > > line4 > > line5 > > line6 > > line7 > > line8 > > line9 > > line10 > > > > > > ############################# > > This was the file after: > > ############################# > > line1line2line3line4line5line6line7line8line9line10 > > No need to use a loop to chomp and print each line, instead: > > chomp(@ary); > print FILE @ary; > > **** [EMAIL PROTECTED] <Carl Jolley> > **** All opinions are my own and not necessarily those of my employer > **** > > _______________________________________________ > Perl-Win32-Users mailing list [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > _______________________________________________ > Perl-Win32-Users mailing list [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs