Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl basics

Status
Not open for further replies.

vijitha123

Programmer
Aug 26, 2008
5
US
Hi,
I am just new to perl.I I have a big perl file.I am trying to find the error.This is just the few lines if file.

#! /usr/bin/perl -w

use strict;


use warnings;
use Apache::Constants qw| REDIRECT OK |;
use Carp;
use Data::Dumper;
use DBI;
use TCO;
use TCO::Init;

### DM-MOD-INLINE - Removing Banned functionality
#use TCO::Banned qw ( get_mid_trust change_mid_trust );

### DM-MOD-FINAL REVIEW

no warnings "redefine";

my ( $dbh , $r , $s , $template ) = TCO::Init::new;

my $bogus = TCO::Init::scrub_params( $r , $s , {
'username' => 32 ,
'password' => 32 ,
'vendor_select_submit' => 32 ,
'vendor_oid' => 20 , # need to change my template for the vendor selection
} );
:::::::::
:::::::::

I am getting this error:Can't locate TCO.pm in @INC
I don't understand..
Module TCO in different directory..So do i have to use 'lib'.
Basically how do you debug your perl in unix...
I would love to hear from any one.

Viji
 

you are right you have to use lib and point it to the directory where the TCO.pm sits

if by debugging you mean check your code before you run it, then the answer is the following
Code:
perl -wc myscript.pl
this will give any syntax or logical errors in your script if there are any.



``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
It sounds like the TCO module (make sure of its case!) is not properly installed. If you're on a system with something vaguely resembling security, wander over to your sysadmin and get him|her to (re)install TCO.

To check this, type

perl -V | more

at the command line; it will show the @INC array Perl is using. Make sure that TCO is in one of the directories it lists.
 
You can use lib or there's a snippet that I use to fix this from time-to-time. Some have tried to guide me away from it but it always worked for me.

Assuming that TCO is installed on the server then you can push the location of the module into @INC which if you weren't sure contains the paths in which files can be included. Some servers have only the path to perl and some default folders related to perl. On one of my testing servers I had gotten the error message when trying to include a file because the file was located beyond my root. Pushing the path into @INC will then allow Perl to use your required file.

----------------------------------------------------------
BEGIN {

push @INC,"/home/
}

----------------------------------------------------------

Just change the path to your folder. Now it will be able to require/use any files you wish within that directory.

The BEGIN forces the perl interpreter to load it before any require/use statements and therefore makes those files available.

Or just use lib. Just thought I'd offer this possible solution in case it ever helps anyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top