#! /usr/bin/perl
use strict;
use warnings;
=head1
print "
----------------------------------ch_5_Q1_--------------------------
";
#print reverse <>;
print "
----------------------------------_--------------------------
";
select STDIN;
my @single_quotation = <>;
print @single_quotation;
print "
----------------------------------ch_5_Q1_--------------------------
";
=cut
print "
----------------------------------ch_5_Q2_--------------------------
";
print "What column width would you like?, please input:";
chomp(my $width = <STDIN>);
print "Enter some lines, then press Ctrl-D:
"; # or Ctrl-z
my @underscore;
chomp(@underscore = <STDIN>);
#@underscore = <STDIN>;
#print "
"."1234567890"x7,"12345
";
print "
"."1234567890"x (($width + 9)/10),"12345
";
=head1
foreach(@underscore){
#print "$_"."
";
printf "%20s
", $_;
}
=cut
my $semicolons = "%${width}s
" x @underscore;
printf "$semicolons", @underscore;
print "
----------------------------------ch_5_Q2_--------------------------
";
自己的答案
#! /usr/bin/perl
use strict;
use warnings;
print "
-------------------------------------tac_-----------------------
";
#foreach(@ARGV){
my $file_number = $#ARGV;
print $file_number;
print "
";
foreach( reverse(0..$file_number) ){
#foreach(<$ARGV[$_]>){
# print $_;
#}
print "$ARGV[$_]
";
my @lines;
open TEMPFD, "< $ARGV[$_]" ;
#@lines = <$ARGV[$_]>;
@lines = <TEMPFD>;
#print @lines;
my $file_lines = $#lines;
foreach( reverse(0..$file_lines) ){
print $lines[$_];
}
close TEMPFD;
}
#}
print "
-------------------------------------tac_-----------------------
";
print "
-------------------------------------_-----------------------
";
print "
----------------------------------_--------------------------
";