[comp.lang.perl] Perl subroutine libraries?

jennifer@bsu-cs.bsu.edu (Jennifer Freeman) (09/25/90)

I have just starting messing around with perl,  and was wondering if there
are any archive sites that might have some subroutines for things such
of Day of Week, or formatting print output for printout out dollars and cents
etc.,   things to study and help prevent having to reinvent the wheel at the
same time.

dmcmilla@rcsdjm.uucp (Don McMillan CS 50) (09/25/90)

In article <11802@bsu-cs.bsu.edu>, jennifer@bsu-cs.bsu.edu (Jennifer
Freeman) writes:
|> 
|> I have just starting messing around with perl,  and was wondering if there
|> are any archive sites that might have some subroutines for things such
|> of Day of Week, or formatting print output for printout out dollars
and cents
|> etc.,   things to study and help prevent having to reinvent the wheel at the
|> same time.

Likewise.... Sounds like a great idea!!
Anybody have anything to contribute????

Don McMillan           __  .   .   Phone: (313) 986-1436
CS Department         /  ` |\ /|   UUCP: {umich,cfctech}!rphroy!rcsuna!dmcmilla
GM Research Labs      | ,_ | | |   CSNet: mcmillan@gmr.com
Warren, MI 48090 USA  \__/ |   |   Internet: dmcmilla%rcsuna.uucp@umich.edu

emv@math.lsa.umich.edu (Edward Vielmetti) (09/26/90)

In article <11802@bsu-cs.bsu.edu> jennifer@bsu-cs.bsu.edu (Jennifer Freeman) writes:

   I have just starting messing around with perl,  and was wondering if there
   are any archive sites that might have some subroutines for things such
   of Day of Week, or formatting print output for printout out dollars and cents
   etc.,   things to study and help prevent having to reinvent the wheel at the
   same time.

Biggest collection of paraperlnalia I know of is at tut.cis.ohio-state.edu
in /pub/perl.			--Ed

cdr@brahms.amd.com (Carl Rigney) (10/03/90)

Here's a simple subroutine to calculate Day of the Week using
Zeller's Congruence, which I've found very useful.  A lot of
the temporary variables could be omitted by making it harder to read.

If Randal wants to turn it into a one-liner that's fine by me. :-)

#!/usr/local/bin/perl
# usage: zeller yyyy mm dd

$day = &weekday(@ARGV);
print $day,"\n";

sub weekday {
	local($year,$month,$day)=@_;
	local($y,$m,$c,$yy,$z);

	local(@wday) = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );

	$y = $year;
	$m = ($month + 10) % 12;
	$y-- if ($m > 10);
	$c = int ( $y / 100 );
	$yy = $year % 100;

	$z = ( int ( (26*$m - 2)/10) + $day + $yy + int($yy/4) + int ($c/4) - 2*$c ) % 7;
	return $wday[$z];
}

--
Carl Rigney
cdr@amd.com
{ames decwrl sun uunet}!amdcad!cdr

"There are no problems in perl, only opportunities for adventure."