perl - Error trying to compare timestamps


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl - Error trying to compare timestamps
# 1  
Old 11-02-2010
perl - Error trying to compare timestamps

Hello,

I have the following snippet of code:
Code:
           my $Temp="";         
   239              #Fix Timestamp
   240              #--------------------------------------------------------------------------------
   241              @initial_date=split(/ /, $field[10]);
   242              @final_date = split("\/",$initial_date[0]);
   243              @time = split("\:", $initial_date[1]);
   244              if($final_date[1]==0)
   245              {
   246                   next;
   247              }
   248                       print($final_date[1]);
   249              $final_date[1]=$final_date[1]-1;
   250              $epochTime = timegm($time[-1], $time[-2], $time[-3], $final_date[0], $final_date[1], $final_date[2]);
   251              $field[10] = $epochTime;
   252              $Temp= $epochTime;
   253              $field[10]=gmtime($field[10]);
   254              #-----------------------------------------------------------------
   255
   256  print("CHECK TIMESTAMP VALUE\n");
   257  print("$TimeTemp\n");
   258  print("END OG CHECK\n");
   259
   260
   261  #############CF start############################
   262  for($TimeStamp=0; $TimeStamp<@TimeStamp; $TimeStamp++ )
   263  {
   264    if(    ($Temp==@TimeStamp[$TimeStamp]+1 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO') || (Temp==@TimeStamp[$TimeStamp]+2 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO'
)  ||  ($Temp==@TimeStamp[$TimeStamp]+3 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO') || (Temp==@TimeStamp[$TimeStamp]+4 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO')  ||    (
$Temp==@TimeStamp[$TimeStamp]+5 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO')  ||   ($Temp==@TimeStamp[$TimeStamp]+6 && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO') || ($Temp==@
TimeStamp[$TimeStamp] && $field[1]==@A_Number[$TimeStamp] && $field[13] eq 'MO')                           )
   265     {
   266
   267        push(@output_cdr, $field[10]); #start time

When i try to run it i get the folloeing error:
bash-3.2$ perl prepaid_voice_new.pl
Bareword "Temp" not allowed while "strict subs" in use at prepaid_voice_new.pl line 264.
Bareword "Temp" not allowed while "strict subs" in use at prepaid_voice_new.pl line 264.
Execution of prepaid_voice_new.pl aborted due to compilation errors.


Any idea why this happens

Moderator's Comments:
Mod Comment Having so many posts, you should be familiar with using code tags. You got a PM with a guide.

Last edited by zaxxon; 11-02-2010 at 08:24 AM..
# 2  
Old 11-02-2010
you are using strict module, so for global scope of Temp us :

Code:
our $Temp

not

my $Temp

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two timestamps and print elapsed time

Hi, I am unable to Difference between two time stamps in Linux and display the total elapsed time . Source date: Aug 15, 2012 02:00:03 Target date: Aug 14, 2012 18:00:03 # based on the forums I am using the below function. Converted dates into this format Src_dt=20120814180003... (7 Replies)
Discussion started by: onesuri
7 Replies

2. Shell Programming and Scripting

Grep 'error' between two timestamps

Hi, Need to grep for a error in a log file but between two timestamps / patterns example: in the below log file if the given timestamps are 14:00 to 15:00 and m greping for error only error3 should come in the output. pls note that apart from timestamps printed, the log file has no... (2 Replies)
Discussion started by: amicableperson
2 Replies

3. Shell Programming and Scripting

[Shell/Perl(?)] Prepending timestamps to console output & writing results to a file

I do a lot of TSM work and I embarked on what I thought would be an easy task, and I'd be very happy for any input to save the pounding my keyboard is receiving :] By default, the output of TSM's console has no timestamping, making it hard to sort through accurately. This puts my console into... (5 Replies)
Discussion started by: Vryali
5 Replies

4. Shell Programming and Scripting

perl: compare two arrays

Hi friends, I want to compare two arrays and find matched one using perl? Also, I want to delete unmatched one. Plz suggest me solution (1 Reply)
Discussion started by: Renesh
1 Replies

5. UNIX for Dummies Questions & Answers

Compare 2 timestamps

Hi, i have current timestamp, lets say "12:02:45" in an variable (var1) and another timestamp "08:30:00" fetched from table in another variable2 (var2). How do i compare 2 timestamps in unix shell scripting. if var 1 > var 2 then echo message. Thanks in advance. (3 Replies)
Discussion started by: prasannarajesh
3 Replies

6. Shell Programming and Scripting

Compare Timestamps

Hi! Long time reader first time registered user and poster. I've picked up some times and tricks and I'm at a dead end... I've parsed a log file for duplicates and printed only the two fields I need (duplicate entry and time stamp). My question is, with this output, how would I script... (2 Replies)
Discussion started by: rexpokinghorn
2 Replies

7. Shell Programming and Scripting

compare 5% and 40% in perl

hi everyone, how to compare 5% and 40% in perl, which one if bigger? Thanks (6 Replies)
Discussion started by: jimmy_y
6 Replies

8. Shell Programming and Scripting

Compare arrays (perl)

Hi, my first post here! Description of my problem: I have one txt-file with six rows and each row contains seven numbers seperated with whitespaces. I want to: Compare one array with seven numbers with each row of numbers in the txt-file. I have managed to compare one array with... (6 Replies)
Discussion started by: mjoh
6 Replies

9. Shell Programming and Scripting

compare 2 arrays in perl

Hi Im supposed to compare lines in a file : KB0005 1019 T IFVATVPVI 0.691 PKC YES KB0005 1036 T YFLQTSQQL 0.785 PKC YES KB0005 1037 S FLQTSQQLK 0.585 DNAPK YES KB0005 1045 S KQLESEGRS 0.669 PKC YES KB0005 1045 S KQLESEGRS 0.880 unsp YES KB204320 1019 T IFVATVPVI 0.699 PKC YES ... (7 Replies)
Discussion started by: karla
7 Replies

10. Shell Programming and Scripting

Perl - Compare 2 Arrays

Hi all, I have the following script where the contents of file1 and file2 would be something like this: file1: 56790,0,0,100998765 89756,0,0,100567876 867645,1,3,678777654 file2: 56790,0,0,100998765 65776,0,0,4766457890 +5896,0,0,675489876 What I then want to do is check if... (4 Replies)
Discussion started by: Donkey25
4 Replies
Login or Register to Ask a Question