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 " ----------------------------------_-------------------------- ";

  • 相关阅读:
    A real ROCA using Bootstrap, jQuery, Thymeleaf, Spring HATEOAS and Spring MVC
    CTP交易接口
    PHP版实现友好的时间显示方式(例如:2小时前)
    php实现文件上传的源码
    获取 Windows Phone 的 User-Agent 字符串
    实现弹出收回菜单效果ios源码
    孤岛能源安卓游戏安卓源码
    火影快打游戏安卓源码
    java编程的78条黄金法则
    php中实现17种正则表达式
  • 原文地址:https://www.cnblogs.com/books2read/p/11004044.html
Copyright © 2011-2022 走看看