newbie01 perl <newbie01.p...@gmail.com> wrote:
> Problem 1:
> - Is there a function to compare the two (2) dates so ensure that I
> will always be doing <future_date>-<past_date>? At the moment, the
> workaround that am doing is if I get a negative value, then that
> means, I've done a <past_date>-<future_date> and need to change
> the way I print the output.

If you factor out the code that prints the output into a subroutine, then 
you're fine.

        # pseudocode
        if( $time_delta < 0 ){
          print_subroutine( $t1, $t2, $delta );
        } else {
          print_subroutine( $t2, $t1, -$delta );
        }

That's actually much nicer than converting your timestamps to, say, time_t, 
then doing a compare and then probably exchanging them.

> Problem 2 is the bigger problem:
> - Now I want to use the same script to run on a UNIX box but
> unfortunately I do not have the Date::Calc module on that server.

You can basically build and install Perl modules in your home directory using 
normal user privileges - that way you would not "mess up" the system if that's 
what the sysadmin is afraid of. You can even "hide" that fact by using PAR / pp 
to bundle up your script, the Perl interpreter and all required modules in a 
single stand-alone binary that can be redistributed across machines if they're 
using the same OS release and architecture.

Of course, there still might be security concerns that prevent you from doing 
that. And if you want to build XS modules like Date::Calc you'll need the 
compiler/libs used to build your perl binary - at least in the good old days 
that meant that you had to have gcc installed.

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to