The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with perl ali560045 Shell Programming and Scripting 6 05-29-2008 04:26 AM
PERL script problem caddyjoe77 Shell Programming and Scripting 5 07-06-2007 11:29 AM
Problem with cat with PERL Substitute jingi1234 UNIX for Advanced & Expert Users 2 03-23-2007 12:11 AM
PERL function problem avadhani Shell Programming and Scripting 2 06-15-2005 01:18 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
Perl problem

I have been recently given a PERL script to develop, but the main problem is that the perl version that I have to use is old, also I cant download modules from CPAN.

Perl version 5.0005

I didnt realise this untill I had the script ready to be tested, so there are a few modules that I have used which are not in the perl version.

So I was wondering if anyone could help with this section of code below.
As in does anyone know how to format it so it will work with th eold version of perl or even know what module to use form the old perl version, which will do the same job I am looking to do.

Any help would be much appriciated.



use Time::HiRes qw( usleep gettimeofday tv_interval );


my $Success = 0;
my $elapsed;
my $start;
#if a failure has occurred

if($Success == 1)
{
# Set Time Interval
my $oneMinute = 60_000_000; # 1 minute
my $numberMinutes = 30; # 30 minutes - CONNECTION TIME - Can be changed
my $loopTime = $oneMinute * $numberMinutes;

#Get start time
$start = [gettimeofday];
while ($elapsed < $loopTime && $Success == 1)
{
connect("","");
$elapsed = tv_interval ($start, [gettimeofday]); #Calc elapsed time
}
}

Last edited by meevagh; 05-09-2008 at 03:03 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-09-2008
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,422
Just want to clarify: your system doesn't have Time::HiRes. Am I right?
Reply With Quote
  #3 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
yes thats correct.

when I try running script, i get a reply(now this is not 100% correct)

can't locate Time::HiRes in perl/bin.....................

I was told that this error is because I dont have the module Time::HiRes, and they I was told I couldnt download it either, so I have to try and find another way
Reply With Quote
  #4 (permalink)  
Old 05-09-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,490
Quote:
also I cant download modules from CPAN.
Is there any good reason why you should not download the modules from CPAN ?

Its not possible to write all the modules by ourselves, CPAN is there to use the modules that we need.
Reply With Quote
  #5 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: Apr 2008
Posts: 6
The main reason basically is that where the perl is installed we have no access to it, and we would need higher authority to access it, which our team lead doesnt want to have to go and ask about.

If it is going to take a mountain of code to work, dont worry about it.

I just thought that surely there must have been some module in the origianl perl version which allowed you to create some kind of code like im trying to achieve
Reply With Quote
  #6 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 294
if that vesion of perl has the "lib" pragma you can use modules by including them in @INC via "lib". See your perl documentation for "lib" and how to use it, but with such an old version of perl you will most likely run into other problems. Time::HiRes hooks into systems C time functions. You can read the documetation and look at the Time::HiRes source code to get ideas.
Reply With Quote
  #7 (permalink)  
Old 05-09-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,502
Following on KevinADC's comment -

You could write small piece of C code to do the job and `mycode args` to get a result in perl.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0