On Fri, 22 Oct 2004 02:05:33 -0700 (PDT), Melis Mutlu
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I would like to write a whole string into a file with
> the following code:
> 
> open(NEW, "new.txt") or die "cannot open new_acl.txt";
> open(OUT, ">test");
> while(my $line=<NEW>) {
>                        chop $line;
>                        $string=$string.$line;
>                        print OUT $string}
> 
> when I open the vi file test, it does not show the
> string and says that line is too long. How can I make
> this string "visible" ? The problem is that I dont
> want new lines.

One question and one tip

Question:
Do you intend to put the input file into the outputfile multiple times?

Tip:
VI fails to open files where file containts lines greater than some arbitrary 
line length (usually around 2000 bytes).  Since you are 'chop'ping off
the carriage returns on input, but not putting then back on output, you
will end up with an output file containing a single line of text...

Try this with an input file made up of say 10 lines, where each line it no
more than 5 characters.  You should then see what is happening.

Also, a freebie:
  When you 'CHOP' a line, you remove the last character.  This allows you
  to consume a line of input text in reverse.  If the last character
was a newline
  then you happen to achieve the same result as 'chomp'.  If the last character
  was in fact important data, you will lose it.   Use CHOMP if you only intend 
  to strip newlines.  Use chop if you want your input lines all one character
  shorter, and you dont care what get chopped off the end.


> 
> Best regards,
> 
> Melis
> 
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
>

-- 
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