Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Text::Table Tutorial

by biohisham (Priest)
on Jun 26, 2010 at 12:26 UTC ( [id://846667]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    Acklay
    10
    ...
    13
    botany
    2053
    
  2. or download this
    #!/usr/local/bin/perl
    use strict;
    ...
    
    close $fh;
    print Dumper(\%students_51,\%students_53);
    
  3. or download this
    #OUTPUT:
    
    ...
                          'age' => '12'
                        }
            };
    
  4. or download this
    use Text::Table;
    my  $table_51 = Text::Table->new("NAME","AGE","TOPIC","CLASS");
    
  5. or download this
    foreach my $key(keys %students_51){
            #Direct interpolation to the add function of Text::Table
    ...
            }
    $table_51->add(' ');   #ADD AN EMPTY Record
    print $table_51;
    
  6. or download this
    #OUTPUT:
    
    ...
    Chiilak  17              2051 
    Blistmok 14  metaphysics 2051 
    Acklay   10  genetics    2051
    
  7. or download this
    #Zuxu record
    my @Zuxu_data = ("Zuxo"," "," ","2053"); #blanks serve as placeholders
    + here
    
  8. or download this
    my $table_53 = Text::Table->new( "NAME\n-----", "AGE\n---", "TOPIC\n--
    +---", "CLASS\n-----" );
    
    ...
    
    print $table_53;
    
  9. or download this
    #OUTPUT:
    
    ...
    Lylek                    2053 
    Massiff 13  botany       2053 
    Zuxo                     2053
    
  10. or download this
    #print the header for $table_53 and Massiff's record.
    foreach(0,1,4){
            print $table_53->table($_);
            }
    
  11. or download this
    #OUTPUT:
    
    NAME    AGE TOPIC        CLASS
    -----   --- -----        -----
    Massiff 13  botany       2053
    
  12. or download this
    #show me 3 records starting from line 2
    print $table_53->table(2,3);
    
  13. or download this
    #OUTPUT:
    
    Bith    12  anthropology 2053 
    Lylek                    2053 
    Massiff 13  botany       2053
    
  14. or download this
    my @headed_table   = $table_53->table();
    my @headless_table = $table_53->body();
    ...
    print @headless_table;
    print "+" x 50, "\n";
    print @headed_table;
    
  15. or download this
    #OUTPUT:
    
    ...
    Massiff 13  botany       2053 
    Zuxo                     2053
    
  16. or download this
    print $table_53->body();
    print "\n\n";
    my $third_record = $table_53->body(2);
    print $third_record;
    
  17. or download this
    #OUTPUT:
    
    ...
    
    
    Massiff 13  botany       2053 <----Third Record only
    
  18. or download this
    #!/usr/local/bin/perl
    use strict;
    ...
    );
    
    print $table_53;
    
  19. or download this
    my @headless_51 = $table_51->body();
    my @headless_53 = $table_53->body();
    print "@headless_51 @headless_53";
    
  20. or download this
    #OUTPUT:
    
    ...
     Massiff 13  botany       2053 
     Zuxo                     2053
    
  21. or download this
    my $merged_tables = Text::Table->new("\tTABLE 51 ","\tTABLE 53");
    $merged_tables->add($table_51->select(0,1,2,3),$table_53->select(3,2,1
    +,0));
    ...
    Blistmok 14  metaphysics 2051  2053                   Lylek  
    Acklay   10  genetics    2051  2053  botany       13  Massiff
                                   2053                   Zuxo
    
  22. or download this
    my $merged_name_age=Text::Table->new("\tAGES OF CLASSES","");
    $merged_name_age->add($table_51->select(0,1),$table_53->select(0,1));
    ...
    Acklay   10      Massiff 13 
                     Zuxo
    
  23. or download this
    my $class_topic=Text::Table->new("Subjects Of Classes","");
    $class_topic->add($table_51->select(2,3),$table_53->select(2,3));
    ...
    genetics    2051     botany       2053 
                                      2053
    
  24. or download this
    # @Dlines  = $table1->body();
    # @DPlines = $table2->body();
    ...
            $alignedTable->load([$D1, $D2]);
            }
    print $alignedTable;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://846667]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-16 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found