zoukankan      html  css  js  c++  java
  • 第五章答案

    #! /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 " ----------------------------------_-------------------------- ";

  • 相关阅读:
    1、springcloud gateway
    -webkit-overflow-scrolling:touch 相关
    SpringBoot(一)原理剖析:SpringApplication启动原理
    JAVA基础面试题
    JVM面试题
    排序(四)选择排序:简单选择排序
    排序(三)插入排序:简单插入排序和希尔排序
    排序(二)交换排序:冒泡排序与快速排序
    排序(一)简介
    多线程面试题
  • 原文地址:https://www.cnblogs.com/books2read/p/11004044.html
Copyright © 2011-2022 走看看