FWIW, I think that what works works, but what doesn't work
doesn't work. Your script isn't working because you're working
too hard at it. There's only five names on the list, so why not hardcode them? I'd suggest taking a break, then go back to the beginning. I took your script and reduced it to a bare minimum
that works. You could start with this skeleton and gradually,
incrementally build upon it. Keep on trying!
#!/usr/lib/perl
use strict;
use warnings;
use Text::Table;
my $tb = Text::Table->new(
"NAME----------",
"Age----------",
"Department-----------");
$tb->load(
["Ram", 25, "HR"],
["Ravi", 28, "HR"],
["Raju", 27, "IT"],
["Ajay", 26, "IT"],
["Rani", 25, "IT"],
);
my $o = '';
$o .= $tb->rule( q{_} );
$o .= $tb->body();
$o .= $tb->rule( q{_} );
open STDOUT, '>-' or die $!;
print my @lines = $tb->table;
close STDOUT;
__END__
The employee name is : Ram
Age: 25 years
Department: HR
The employee name is : Ravi
Age: 28 years
Department: HR
The employee name is : Raju
Age: 27 years
Department: IT
The employee name is : Ajay
Age: 26 years
Department: IT
The employee name is : Rani
Age: 25 years
Department: IT
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.