Re: One sprintf() initializations problem



On 10/29/07, jiangfan <Jiangfan.Shi@xxxxxxxxx> wrote:

What is wrong with this statement?

my $time = sprintf( "0x%08x", `date +%s` );

I don't know what's wrong with it on your machine, but I'd change the
command in backticks to be Perl's time operator:

my $time = sprintf("0x%08x", time);

Doesn't that do the same thing? Most simple shell commands aren't
needed from Perl.

"Use of uninitialized value in sprintf at /opt/MoteWorks/tos/../make/
scripts/ident_flags line 15."

Maybe your date command doesn't support that format. But Perl's time
operator should work everywhere.

Cheers!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: backtick and system return different exit codes
    ... > backticks cause it is returning the correct output. ... > I am not really interested in knowing the exact error code.i ... > want to know whether the command executed successfully. ...
    (comp.lang.perl.misc)
  • [SLE] Re: PHP Safe Mode ?
    ... > Ok, I check that and changed it to backticks, it changed the error I got. ... Sorry - I meant backticks if you're just using the command by itself: ... echo $return; ... that they will never work first time around. ...
    (SuSE)
  • Re: invoking system commands from a perl script
    ... >> so using backticks or system is teh same thing except when you want to ... >> capture the result value of teh command. ... >> question was that somebody told me, that using system to execute unix ... a> command has been executed, ...
    (comp.lang.perl.misc)
  • `(bacticks) returns "Bad File Descriptor" error with Apache
    ... I wanted to run a command line program from Ruby. ... run it using Apache 2.2.8, a "Bad File Descriptor" error is returned. ... Using `(backticks) to run ...
    (comp.lang.ruby)
  • Re: find
    ... Those backticks make the shell interpret what's inside them as a command and ...
    (Fedora)