thanos1983 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
Although that this question should have a simple answer I can not understand where I am going wrong. I am using a Linux OS and I executing the following part of code:
#!/usr/bin/perl use strict; use warnings; use Time::HiRes qw( clock_gettime clock_getres ); my $realtime = clock_gettime('CLOCK_REALTIME'); my $resolution = clock_getres('CLOCK_REALTIME'); print "Realtime: ".$realtime."\n"; print "Resolution: ".$resolution."\n";
I am getting this error:
Argument "CLOCK_REALTIME" isn't numeric in subroutine entry at test.pl + line 6. Argument "CLOCK_REALTIME" isn't numeric in subroutine entry at test.pl + line 7. Realtime: 1411038919.69833 Resolution: 1e-09
According to Time::HiRes the syntax should not include the single quotes and it should be modified accordingly:
#!/usr/bin/perl use strict; use warnings; use Time::HiRes qw( clock_gettime clock_getres ); my $realtime = clock_gettime(CLOCK_REALTIME); my $resolution = clock_getres(CLOCK_REALTIME); print "Realtime: ".$realtime."\n"; print "Resolution: ".$resolution."\n";
But I get the following error when I execute the code:
Bareword "CLOCK_REALTIME" not allowed while "strict subs" in use at te +st.pl line 6. Bareword "CLOCK_REALTIME" not allowed while "strict subs" in use at te +st.pl line 7. Execution of test.pl aborted due to compilation errors.
Any ideas why I am getting this error on both cases?
Thank you in advance for your time and effort to assist me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Argument "CLOCK_REALTIME" isn't numeric in subroutine entry
by Corion (Patriarch) on Sep 18, 2014 at 11:18 UTC | |
by thanos1983 (Parson) on Sep 18, 2014 at 11:33 UTC |