Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

→‎{{header|Perl}}: prepend pascal
No edit summary
(→‎{{header|Perl}}: prepend pascal)
Line 144:
"Diplomacy is the art of
>>>>></pre>
 
=={{header|Pascal}}==
{{works with|Free Pascal}} maybe {{works with|Delphi}}
<lang pascal>program TAC;
{$IFDEF FPC}
{$MODE DELPHI}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
uses
sysutils, classes;
var
Sl:TStringList;
i,j : nativeInt;
begin
Sl := TStringList.Create;
Sl.Loadfromfile('Rodgers.txt');
i := 0;
j := Sl.Count-1;
While i<j do
Begin
Sl.Exchange(i,j);
inc(i);
dec(j);
end;
writeln(Sl.text);
end.</lang>{{out}}
<pre> --- Will Rodgers
 
until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of</pre>
 
=={{header|Perl}}==
Anonymous user