0
use Text::Table; 
my $tb = Text::Table->new(“Planet”,”Radius\nkm”,”Density\ng/cm^3”);
$tb->load(
[ “Mercury”,2360,3.7],
[ “Mercury”,2360,3.7],
[ “Mercury”,2360,3.7],
);
Print $tb;

I'm executing the above perl snippet to create the table with the data. But i'm getting an error as

Can't locate Text/Table.pm in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64/
lib .) at table.pl line 1.
BEGIN failed--compilation aborted at table.pl line 1.

I'm using Activeperl,Selenium RC. Should i need to download any packages for the table ? or any other better ways to create a table apart from this ?

Jackie James
  • 785
  • 8
  • 15
  • 28
  • It means you do not have Text::Table installed. To answer the rest of your question, you will have to explain what you are trying to accomplish when you say "create a table". – Dondi Michael Stroma Jun 18 '12 at 05:54
  • @ Dondi Michael Stroma : I'm just creating a table with the headings Planet,Radius & Density. And under this, I need to print the data above mentioned. I think this is the simple way of creating a table. But i don't know why i'm unable to do it. – Jackie James Jun 18 '12 at 06:15
  • From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [What's the easiest way to install a missing Perl module?](http://stackoverflow.com/questions/65865/whats-the-easiest-way-to-install-a-missing-perl-module) – daxim Jun 18 '12 at 08:19

1 Answers1

2

The most common reason for Perl not being able to find a module is because it's not installed. Try

ppm install Text::Table

or if it fails,

cpan Text::Table

Note that your code is invalid. You tried to use

“, U+201C, LEFT DOUBLE QUOTATION MARK, and
“, U+201D, RIGHT DOUBLE QUOTATION MARK

but the quote character you need to use is

", U+0022, QUOTATION MARK
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • @ ikegami : After installing Text::Table from ppm, i executed the above snippet nw i'm getting an error as Unrecognized character \x93; marked by <-- HERE after ble->new( <-- HERE near co lumn 28 at table.pl line 2. – Jackie James Jun 18 '12 at 06:13
  • 1
    Your quotation marks are not `"` signs (doulbe quotes from your keyboard), but rather quotation marks. Change them and don't write your code in a word processor. If you don't find them in your keyboard, try using q() instead. See http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators – simbabque Jun 18 '12 at 06:38
  • @ Simbabque : is below snippet right ? use Text::Table; my $tb = Text::Table->new(qq{ Planet,Radius,Density}); $tb->load( [ “Mercury”,2360,3.7], [ “Mercury”,2360,3.7], [ “Mercury”,2360,3.7], ); Print $tb; Getting error as "C:\Scripts>perl table1.pl Unrecognized character \x93; marked by <-- HERE after [ <-- HERE near column 3 a t table1.pl line 4." I'm writing this snippet in notepad & then saving it as filename.pl – Jackie James Jun 18 '12 at 06:48
  • No, it's not ok,like both Perl and simbabque are telling you. Added a few notes on it to my answer. – ikegami Jun 18 '12 at 07:42