try
sub getEpochSeconds {
my $TIMEVAL_T = "LL"; # LL for microseconds
my $start = pack($TIMEVAL_T, ());
syscall(&main::SYS_gettimeofday, $start, 0) != -1 or die "seconds: $!";
return( (unpack($TIMEVAL_T, $start))[0] );
}
sub getEpochSeconds {
my $TIMEVAL_T = "LL"; # LL for microseconds
my $start = pack($TIMEVAL_T, ());
syscall(&SYS_gettimeofday, $start, 0) != -1 or die "seconds: $!";
return( (unpack($TIMEVAL_T, $start))[0] );
}
For some odd reason when i execute my script I get an error on the syscall() line:
seconds: Invalid argument at line 79
Any ideas?
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
try
sub getEpochSeconds {
my $TIMEVAL_T = "LL"; # LL for microseconds
my $start = pack($TIMEVAL_T, ());
syscall(&main::SYS_gettimeofday, $start, 0) != -1 or die "seconds: $!";
return( (unpack($TIMEVAL_T, $start))[0] );
}
No luck. It seems like it may be the die that's borking. When I take it out I get no error message. It also seems to see !$ as an invalid argument.
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
Always Works For Me
Very true...I won't have to see the error message again if I shatter my laptop in to it's own physical array.Originally Posted by LAURENU2
I'm beginning to think maybe there is an issue with the system call, but I don't believe so. I made sure I had syscall.ph available and I even recreated it by converting the syscall.h to syscall.ph again.
I even isolated the code from the script and made a separate test script:
I still get the same error. I've tryed changing it the syscall line to:Code:#! /usr/bin/perl -w require 'sys/syscall.ph'; my $start = pack("LL", ()); syscall(&SYS_gettimeofday, $start, 0) != -1 or die "seconds: $!";
Same error message. I tried changing 0 to undef and same thing. If I changed it to:Code:syscall(&main::SYS_gettimeofday, $start, 0) != -1 or die $!;
I get "Died at test.pl line 4. It seems to be an issue with die handling arguments?Code:syscall(&SYS_gettimeofday, $start, 0) != -1 or die;
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
Does it have anything to do with the fact that your pack() isn't returning 'anything'?
Originally Posted by Darkness Productions
It does it regardless of what's going on with pack. The only thing my test script has now is:
my $TIMEVAL_T = "LL"; # LL for microseconds
my $start = pack($TIMEVAL_T, ());
syscall(&SYS_gettimeofday, $start, 0) != -1 or die "seconds: $!";
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
Works fine almost as it is on FreeBSD with perl 5.8.8, I just had to change "&SYS_gettimeofday" to "116" as detailed in syscall.ph (/usr/local/lib/perl5/site_perl/5.8.8/mach/sys/syscall.ph). It doesn't come up with any error regarding "seconds" when I run it.
Though I agree with DP, it seems as though the pack call is setting $start to nothing.
mag:
May I ask, what exactly are you trying to accomplish? Getting the number of microseconds from the epoch, on 64-bit hardware?
From the information I can gather, that's what this is designed to do...
Actually, ignore that statement. What version of perl are you on?
Perl 5.8.8 is what I'm using (Ubuntu x86). I'm actually modifying a script to utilize the accelerometer in my Thinkpad to do usefull things when I bump it (using hdaps kernel module).
Currently I just have a C script that rotates my Beryl desktop cube (original author's video) when I bump it to the right or left. It was originally written for Compiz, but I modified it to work with Beryl.
I want to get this Perl script working though.
I just posted that function, however there are multiple ones that just won't work in the same fashion. I figure if I can fix one I can fix them all. I posted the same question at PerlGuru.com and no one has even responded.
Last edited by magnav0x; 07-10-2007 at 05:38 PM.
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
The only reason I ask, is that I have the following (working!) script:
Code:#!/usr/bin/perl -w require "sys/syscall.ph"; $start = &getEpochSeconds(); sleep(3); $done = &getEpochSeconds(); $deltatime = sprintf("%.4f", ($done)-($start)); print $deltatime; sub getEpochSeconds { my $TIMEVAL_T = "LL"; my $timer = pack($TIMEVAL_T, ()); syscall(&SYS_gettimeofday, $timer, 0) != -1 || die "gettimeofday: $!"; return ((unpack($TIMEVAL_T, $timer))[0]); }
on 5.8.8...
What OS are you using? I'm wondering if something on my system is screwed (possibly my syscall.ph?). I've Googled until my fingers started to bleed and I found nothing similar to my issue.Originally Posted by Darkness Productions
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
They maybe able to help here also. http://tek-tips.com/threadminder.cfm?pid=219 it is a Perl forum
Life is Just a Big Role Playing Adventure
Thanks for the link. I'll give them a go.Originally Posted by Sleepsalot
Warning this Post is Rated "M" for Mature
-Contains Harsh Language
-L337 HaX0r W3RD2!
-Partial Nudity
I haven't lost my mind; it's backed up on tape drive somewhere.
On debian testing...