Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

wog

by wog (Curate)
on Mar 25, 2001 at 08:16 UTC ( #66950=user: print w/replies, xml ) Need Help??

"It's sad. I always find things in the last place I look for them."

@gatech.edu

my scratch pad

perl -e '$|--;$.=q$.$;while($i!=0){$i=(time-$^T)%60;print"\r".$.x$i}'

# -- MeaningOfLifeTheUniverseAndEverything.pm -- package MeaningOfLifeTheUniverseAndEverything; use strict; sub _create { bless \(my $_42 = 42) } sub _value { 42 } use overload '0+' => \&_value, 'nomethod' => \&_create; sub import { overload::constant integer => \&_create, float => \&_create; } sub unimport { use Carp; croak "You can't get rid of the Meaning of Life, " ."the Universe, and Everything"; } q{ 32 }; __END__ =head1 NAME MeaningOfLifeTheUniverseAndEverything =head1 SYNOPSIS use MeaningOfLifeTheUniverseAndEverything; =head1 DES‎CRIP‎TION This module replaces all other numbers with the answer to the ultimate quesiton of life, the universe and everything throughout the program it is run from. =head1 NOTE It is a fatal error to attempt to get rid of the meaning of life, the universe and everything. =head1 BUGS This module cannot turn nothing (a literal 0) into the answer. This is of course perl's fault, since anything associated with HHGTG wouldn't have such obvious faults (unless the guide gets taken over by some evil company or something like that.) =head1 SEE ALSO I<The Hitchhiker's Guide to the Galaxy>. =cut # -- test.pl -- #!/usr/bin/perl -w use strict; use MeaningOfLifeTheUniverseAndEverything; sub value { (defined $_[0]) ? $_[0] : 'undef'; } sub show { foreach my $expr (@_) { print $expr, " = ", value(eval $expr), "\n"; print "(error: $@)\n" if $@; } } show split /\n/ => <<'END'; 4.2 * 10 4.2 * 9 + 1 2 + 2 42 - 1 3 % 2 0 END

sub warningless_require_module { # * untested * use File::Spec; use Carp; my $module = shift; my @module = split /::/, $module; $module[-1] .= ".pm"; my $file; for (@INC) { $file = File::Spec->catfile($_,@module); last if -f $file; } if (!-f _) { die "Can't locate $file in \@INC (\@INC contains @INC)\n"; } my $res; { local $^W = 0; $res = do $file; } unless ($res) { die $@ if $@; croak "file didn't return a true value"; } $INC{File::Spec->catfile(@module)} = $file; { no strict 'refs'; foreach my $raw_name (keys %{$module."::"}) { my $name = $module."::".$raw_name; if (defined &{$name}) { my $sub = \&{$name}; *{$name} = sub { local $^W = 0; &$meth; }; } } } return $res; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[james28909]: ill be back with a solution eventually
[stevieb]: it's a reminder to re-inforce it :P
[atcroft]: james28909: That particular questions was a bit of trick, actually (depending on the country you are in). More interesting is, if you are trying to subtract from an epoch time, for instance, you might have to consider when/if DST occurs for a location,
[atcroft]: because you may have to adjust the number of seconds you change from an epoch from 86400 (not to mention leap seconds)....
[atcroft]: james28909: Although if your program is using a database, you might be able to "pass the buck" to the database and ask it to do the date change for you....

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2017-04-29 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.