The last line of the following program is not able to read the file Data file = MultiLineData.txt 19760 Austria 7800 Kingsland 124 Petrie Terrace 19762 19764 19765 19767 Austria 7864 Kingsland 1/249 Coronation Drive 19768 19770 Austria 7853 Kingsland Lawrence: 103 Frasers Rd 19771 19775 Austria 7800 Kingsland 127 Edward Street 19777 19779 19780 Austria 7963 Kingsland 133 King Street 19782 19784 19785 19787 19789 19791 Austria 7800 Kingsland Riverside Centre Level 29 123 Eagle Street 19793 19795 19796 19799 67301 67302 67304 Austria 7810 Kingsland Argyle Office Suit 9 20 Argyle Street 67306 67308
use strict; use warnings; my $dir = 'C:\Scripts'; open(my $fh1, '<', "$dir\\MultiLineData.txt") or die $!; open(my $out1, '>', "$dir\\work.txt") or die $!; open(my $fh2, '<', "$dir\\work.txt") or die $!; while (my $row = <$fh1>) { chomp $row; my $str = $row; $str =~ s/\t/|/g; print $out1 "$str\n"; } while (<$fh2>){chomp $_; print "$_\n"};

In reply to Perl not able to read file by Anonymous Monk

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.