If $NOW
is out of quotation marks, it becomes space-separated.
$ perl -E'say 0+@ARGV ; say for @ARGV' $NOW 7 perl -e 'use Time::HiRes qw(time); print time'
You can surround the variable with double quotes to avoid this:
$ perl -E'say 0+@ARGV ; say for @ARGV' "$NOW" 1 perl -e 'use Time::HiRes qw(time); print time'
But you want to execute this line as a shell command. Use eval
for this.
$ eval "$NOW" 1335602750.57325
Finally, to assign it, we use the return outputs (or the equivalent of $( ... )
).
$ START_TIME=$(eval "$NOW") $ echo $START_TIME 1335602898.78472
The previously published feature is clearly cleaner, but you said you want help with quoting.
By the way
perl -e 'use Time::HiRes qw(time); print time'
can be reduced to
perl -MTime::HiRes=time -e'print time'
and even to the following (since the final newline fits perfectly):
perl -MTime::HiRes=time -E'say time'
Or if you really wanted to play golf:
perl -MTime::HiRes=time -Esay+time
source share