I wrote this short thing below for you to further expand on toolic's post. turn CHOMP on and off and you will see what that does. Perl can processes lines character by character, but that is in practice seldom used because regex (regular expressions) are a built-in part of the language. You have an answer to your explicit question, but perhaps if you back up and explain what you are trying to accomplish, you might get a better solution to the overall problem.
#!/usr/bin/perl -w use strict; print "Program Running\n"; # Below, I use the standard already opened DATA handle # instead of your open() # open FILE, "<", "Readme.txt" or die $! ; # the "=" stuff is a trick using a markup language # called perldoc to add text within the code so here # that the comment text doesn't get confused with the DATA. use constant CHOMP => 0; #change to 1 to see what happens while (<DATA>) { chomp if CHOMP; #deletes "new line" if enabled my @characters = split(//,$_); my $i=0; foreach my $char (@characters) { print $i++, " $char\n"; } } =Program Outputs the following: Program Running 0 S 1 o 2 m 3 e 4 5 S 6 t 7 u 8 f 9 f 10 Note: this is the \n in the input string followed by the \n in the print 0 a 1 s 2 d 3 f 4 =cut __DATA__ Some Stuff asdf

In reply to Re: Splitting each line into an array from file by Marshall
in thread Splitting each line into an array from file by perly_newbie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.