Cześć,
Mam pewien problem, chciałbym wyświetlić w konsoli jednolinijkowy plik(notatnik), ale tak by po każdym zdaniu wstawiał "\n". Piszę to w Perlu i moim zdaniem taki kod powinien działać:
use warnings;
use strict;
my $current = ""; #obecna linia
$\ = " "; #tak zeby while szedł po słowach
while (<>){
if ($current ne $ARGV){
$current = $ARGV;
print "\n\t\tFile: $ARGV\n\n";
}#wyswietlanie nazwy pliku
if ($_ =~ /([a-z]+\.)/){#Myslałem, ze ten regexp złapie mi słówko zakończone kropką
print $_."\n";
}else{
print $_;
}
}
Być może w tekście jest jakiś złośliwy szczegół. Używam tego wzorca:
1066 In this year the monastery at Westminster was hallowed on Childermas day (28 December). And king Eadward died on Twelfth-mass eve (5 January) and he was buried on Twelfth-mass day, in the newly hallowed church at Westminster. And earl Harold succeeded to the Kingdom of England, as the king had granted it to him and men had also chosen him thereto and he was blessed as king on Twelfth-mass day. And in the same year that he was king he went out with a naval force against William ... And the while count William landed at Hastings, on St. Michael's mass-day and Harold came from the north and fought against him before his army had all come and there he fell and his two brothers Gyrth and Leofwine and William subdued this land, and came to Westminster and archbishop Ealdred hallowed him king and men paid him tribute and gave him hostages and afterwards bought their land
Problem może się wydawać trywialny, ale jestem początkujący, a wydaje mi się, ze używanie tych wyrażeń wymaga większego obycia.
Z góry dzięki za pomoc