Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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"};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl not able to read file
by choroba (Cardinal) on Sep 22, 2017 at 06:31 UTC | |
by Laurent_R (Canon) on Sep 22, 2017 at 09:49 UTC | |
by choroba (Cardinal) on Sep 22, 2017 at 09:55 UTC | |
by Laurent_R (Canon) on Sep 22, 2017 at 10:04 UTC | |
|
Re: Perl not able to read file
by Corion (Patriarch) on Sep 22, 2017 at 06:31 UTC | |
|
Re: Perl not able to read file
by thanos1983 (Parson) on Sep 22, 2017 at 08:55 UTC |