[11366] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4966 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 11:27:21 1999

Date: Fri, 26 Feb 99 08:19:50 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4966

Today's topics:
        Downloading a binary <hunt@queen.es.hac.com>
    Re: Downloading a binary (David Efflandt)
    Re: Downloading a binary <hunt@queen.es.hac.com>
        Dumb Newbie question (VisualJP)
    Re: Dumb Newbie question <jeffp@crusoe.net>
    Re: Dumb Newbie question <wfunk@dev.tivoli.com>
        E-Mail to Database <james@travelcom.net>
    Re: E-Mail to Database (Clay Irving)
    Re: easily generating SQL queries using perl? <gcopeland@NOSPAMvectrix.com>
    Re: efficient , -> TAB substitution? <trent@mail.utexas.edu>
    Re: efficient , -> TAB substitution? (Mick Farmer)
    Re: efficient , -> TAB substitution? <uri@home.sysarch.com>
    Re: efficient , -> TAB substitution? <uri@home.sysarch.com>
        Email from Perl on NT wyndo@cxo.com
    Re: Email from Perl on NT (Mark P.)
    Re: Email from Perl on NT (tony summerfelt)
    Re: Email from Perl on NT <metcher@spider.herston.uq.edu.au>
        error message olmert@netvision.net.il
    Re: error message <gellyfish@btinternet.com>
        escaping in CSV (was Re: Converting CSV to LDIF) <Russell_Schulz@locutus.ofB.ORG>
        Executing SSI from CGI Output <mwatkins@promotion4free.com>
    Re: Executing SSI from CGI Output dhosek@webley.com
    Re: FAQ 4.13: How can I find the Julian Day? (Larry Rosler)
    Re: FAQ 4.13: How can I find the Julian Day? smithj@statenislandonline.com
    Re: FAQ 4.13: How can I find the Julian Day? <tchrist@mox.perl.com>
    Re: FAQ 4.13: How can I find the Julian Day? (Hans-Georg Rist)
    Re: FAQ 4.20: How do I find matching/nesting anything? (Damian Conway)
        FAQ 4.26: How can I count the number of occurrences of  <perlfaq-suggestions@perl.com>
        FAQ 4.27: How do I capitalize all the words on one line <perlfaq-suggestions@perl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 22 Feb 1999 11:40:54 -0800
From: KC <hunt@queen.es.hac.com>
Subject: Downloading a binary
Message-Id: <36D1B2C6.8FA7073D@queen.es.hac.com>

I know this is a simple thing but I cannot do it! I have a binary file
that I want to download through the browser (click the link and
download). The routine that is called after you click the link is:

	print "Content-type: application/octet-stream\n\n";

	open(IN, "<$bebop[2]");
	read OUT, $binary_data, 209547;
	while (<IN>) {
		$buf1 = $_;
		if(!eof(IN)) {
			print "$buf1";
		} else {
			print "$_";
		}
	}
	close (IN);
	exit;

The 209547 is the file size. I wont necessarily know that size going in,
but I'm still experimenting. I can download or display text data with no
problems, but straight binaries give me headaches! Any ideas?
-- 
-----

KC


------------------------------

Date: 23 Feb 1999 07:00:48 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Downloading a binary
Message-Id: <slrn7d4kf4.126.efflandt@efflandt.xnet.com>

On Mon, 22 Feb 1999 11:40:54 -0800, KC <hunt@queen.es.hac.com> wrote:
>I know this is a simple thing but I cannot do it! I have a binary file
>that I want to download through the browser (click the link and
>download). The routine that is called after you click the link is:
>
>	print "Content-type: application/octet-stream\n\n";
>
>	open(IN, "<$bebop[2]");
>	read OUT, $binary_data, 209547;
>	while (<IN>) {
>		$buf1 = $_;
>		if(!eof(IN)) {
>			print "$buf1";
>		} else {
>			print "$_";
>		}
>	}
>	close (IN);
>	exit;
>
>The 209547 is the file size. I wont necessarily know that size going in,
>but I'm still experimenting. I can download or display text data with no
>problems, but straight binaries give me headaches! Any ideas?

A followup msg said to ignore the OUT in the read statement, but the read
statement shouldn't be there at all.  That probably moves the file pointer
so there is nothing left for 'while (<IN>) ('.  The following works
except with brain dead MSIE (which ignores MIME).  So you have to tell
MSIE users to right clidk on the link to this script.

	$len = -s $bebop[2];
	print "Content-type: application/octet-stream\n";
	print "Content-length: "$len\n\n";

	open(IN, "<$bebop[2]");
	print <IN>;
	close IN;
	exit;

And if your server is Windows, you also need a binmode statement between
the open and print.

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


------------------------------

Date: Mon, 22 Feb 1999 11:47:08 -0800
From: KC <hunt@queen.es.hac.com>
Subject: Re: Downloading a binary
Message-Id: <36D1B43C.72763A96@queen.es.hac.com>

Ignore the FileHandles (IN OUT), I know they don't match...
-- 
-----

KC


------------------------------

Date: 24 Feb 1999 16:00:05 GMT
From: visualjp@aol.com (VisualJP)
Subject: Dumb Newbie question
Message-Id: <19990224110005.23523.00002696@ng115.aol.com>

I want to start an executable from my perl script.

If I typed it manually it would look like this:

hmopengl30 -cgeneric.cmf

This is the command that I am trying to use:

system('hmopengl30 -cgeneric.cmf');

Does this look right?  I also tried using "exec" instead of "system" and got
the same result.  It may be due to some outside problems, but I want to
eliminate my Perl script as a possiblilty.

Thanks,
John 


------------------------------

Date: Wed, 24 Feb 1999 11:44:13 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Dumb Newbie question
Message-Id: <Pine.GSO.3.96.990224114311.19685J-100000@crusoe.crusoe.net>

> system('hmopengl30 -cgeneric.cmf');
> 
> Does this look right?  I also tried using "exec" instead of "system" and got
> the same result.  It may be due to some outside problems, but I want to
> eliminate my Perl script as a possiblilty.

You never said WHAT the result was.

If you want output from the command, use qx(...) instead of system().
exec() will replace the current program with the program given it.

And you may want to include a pathname, to be safe.

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



------------------------------

Date: Wed, 24 Feb 1999 11:37:34 -0600
From: "Wade T. Funk" <wfunk@dev.tivoli.com>
Subject: Re: Dumb Newbie question
Message-Id: <36D438DE.FB0EFFE6@dev.tivoli.com>

You can either use system("commad") or backticks which are ``.

e.g.  $result=`hmopengl30 -cgeneric.cmf`;
-- 
Wade T. Funk
Systems Administrator
Tivoli Systems, Inc.
(512) 436-8302


------------------------------

Date: Mon, 22 Feb 1999 14:07:09 -0800
From: James Alspach <james@travelcom.net>
Subject: E-Mail to Database
Message-Id: <36D1D50D.2BD61AF4@travelcom.net>

How can I parse  structured email messages and send them to an sql
database.  I have a web based setup form which is hosted by a company
that will not host my database.  They will, however, email me the
results of the form.  I need to take those results and drop them into a
database.
thanks in advance
james

--


James Alspach
Platform Systems Administrator
Travel Communications Company
www.travelcom.net
<james@travelcom.net>





------------------------------

Date: 22 Feb 1999 17:57:04 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: E-Mail to Database
Message-Id: <slrn7d3o5v.jco.clay@panix.com>

On Mon, 22 Feb 1999 14:07:09 -0800, James Alspach <james@travelcom.net> wrote:

>How can I parse  structured email messages and send them to an sql
>database.  I have a web based setup form which is hosted by a company
>that will not host my database.  They will, however, email me the
>results of the form.  I need to take those results and drop them into a
>database.

Mail::Internet

(part of the Mail::Tools bundle)
http://www.perl.com/CPAN/modules/by-module/Mail
   
   NAME
        Mail::Internet - manipulate Internet format (RFC 822) mail
        messages
   
   SYNOPSIS
            use Mail::Internet;
   
   
   DESCRIPTION
        This package provides a class object which can be used for
        reading, creating, manipulating and writing a message with
        RFC822 compliant headers.
[...]

-- 
Clay Irving <clay@panix.com>
Never lose your sense of the superficial. 
- Lord Northcliffe 



------------------------------

Date: Tue, 23 Feb 1999 12:14:15 -0600
From: "George Copeland" <gcopeland@NOSPAMvectrix.com>
Subject: Re: easily generating SQL queries using perl?
Message-Id: <7auquj$rof$1@newshost.cyberramp.net>

Having a code tool would be nice, but the optimum place for this
functionality would be in the query engine of the data layer.  The new
version of MS SQL Server has "English query" functionality that might meet
your needs.

http://www.microsoft.com/sql/70/gen/eq.htm

Unfortunately, you can't access this functionality via ODBC, so the solution
is not cross-platform.

- - - - - - - - - - - - - - - - - - - - - - - - - - -
- George Copeland
- Vectrix Corporation, Publishers of EdgeworX
- http://www.vectrix.com/edgehome.htm


Matt Arnold wrote in message ...

>Does anyone out there have a module, code fragment, tool, or other resource
>they use to create SQL based on form input?  I'm too lazy to reinvent this
>particular wheel.  And laziness is, after all, one of the virtues of a perl
>programmer.





------------------------------

Date: Mon, 22 Feb 1999 09:03:40 -0600
From: Robert D Trent <trent@mail.utexas.edu>
To: Uri Guttman <uri@home.sysarch.com>
Subject: Re: efficient , -> TAB substitution?
Message-Id: <Pine.GSO.3.96.990222084734.185A-100000@piglet.cc.utexas.edu>

On 19 Feb 1999, Uri Guttman wrote:
> i am surprised at this result. sed is fairly fast and should not be 10
> time slower than perl. so my thought is why was your sed script using -n
> and then the p command? why not just use sed's builtin print (remember
> perl's -p loop imitates sed's default loop)? maybe the extra command
> slows it down.  so benchmark this:
> sed -e 's/","/"      "/g' $argv[1] > $argv[2]
~~~~~~~~~~~~~~~~~
My novice ways are showing, huh? I mistakenly thought the only lines that
would print would be the ones that had successfull substitutions... So I
used the p command and suppressed normal output to keep the substituted
lines from printing twice.  Well, just as I was reading the above I was
testing this and believe it or not, my suppression of output and subsequent
print command were the culprits in the sluggish behavior.  Your sed command
was just as fast as the perl -pi approach.

Thanks to all who helped lead this newbie through a simple task!

- Robert



------------------------------

Date: Tue, 23 Feb 1999 13:27:28 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: efficient , -> TAB substitution?
Message-Id: <F7M01s.pG@mail2.ccs.bbk.ac.uk>

Dear Uri,

Surely, for simple character replacement tr/// is faster.

Regards,

Mick


------------------------------

Date: 22 Feb 1999 13:02:33 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: efficient , -> TAB substitution?
Message-Id: <x7zp66jozq.fsf@home.sysarch.com>

>>>>> "RDT" == Robert D Trent <trent@mail.utexas.edu> writes:

  RDT> On 19 Feb 1999, Uri Guttman wrote:
  >> slows it down.  so benchmark this:
  >> sed -e 's/","/"      "/g' $argv[1] > $argv[2]

  RDT> My novice ways are showing, huh? I mistakenly thought the only
  RDT> lines that would print would be the ones that had successfull
  RDT> substitutions... So I used the p command and suppressed normal
  RDT> output to keep the substituted lines from printing twice.  Well,
  RDT> just as I was reading the above I was testing this and believe it
  RDT> or not, my suppression of output and subsequent print command
  RDT> were the culprits in the sluggish behavior.  Your sed command was
  RDT> just as fast as the perl -pi approach.

but the perl method has several advantages. first the -i switch which
will overwrite the file. the shell/sed method can't do that in one
command. perl's regex is much more powerful than sed's basic version. if
you wanted to do anything more than a plain s/// then perl should
win. for example if you really only wanted to print when a substitution
worked, sed might not be able to do that but perl can easily with

perl -ne 'print if s/foo/bar/'

having the full grammar of a procedural language for use in one liners
is neato!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


------------------------------

Date: 23 Feb 1999 23:20:35 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: efficient , -> TAB substitution?
Message-Id: <x7r9rgjuuk.fsf@home.sysarch.com>

>>>>> "MF" == Mick Farmer <mick@picus.dcs.bbk.ac.uk> writes:

  MF> Surely, for simple character replacement tr/// is faster.

that would fail for this case as he wanted only the commas between
quoted strings converted to tabs. tr/// will not work with commas inside
the quoted strings.

i do know tr/// vs s/// and i point out the difference many times in
this group. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


------------------------------

Date: Tue, 23 Feb 1999 21:07:44 GMT
From: wyndo@cxo.com
Subject: Email from Perl on NT
Message-Id: <7av5ap$1m5$1@nnrp1.dejanews.com>

This *might* not be a Perl question, but I'm not sure where else to start.

I have a large web-based multiplayer role playing game
(http://www.lunatix-online.com) written in Perl. Originally on a UNIX-based
system, I have a section of code that takes the new-player info and emails it
to the new player (to give him/her a validation number) and carbon copies me.
This was done using a Perl call to sendmail and it works fine.

However, that server was only a 486/Dx2-66 and just didn't have the power to
support a busy game with many players logged in. So, my web host (a local
provider) moved me to a new machine which is much more powerful and supports
the game very well. However, this new machine is on an NT system using
ActivePerl. The only problem I have not been able to resolve is the issue of
sending this new player letter.

I have "patched" the problem by leaving a small CGI email script on the old
server, which gets "called" (a tricky thing of using the image.src property in
JavaScript) by a page generated on the new server. This has actually been
working fine for the past two or three months.

However, we plan to sell game licenses to other servers and anybody using NT
is going to have this problem -- I don't want to ask them to run an
additional UNIX server for the sole purpose of sending a new player email --
it's fine for us, but definitely not a marketable solution.

My web host was supposed to provide the answer for me, but they have not. Does
anybody know what the equivalent of "sendmail" is for an NT system?

Mike Snyder
http://www.lunatix-online.com/ (Lunatix Online: Global Insanity Crisis)
http://www.prowler-pro.com/logic/ (Lunatix Online Home Page)

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 23 Feb 1999 23:01:14 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: Email from Perl on NT
Message-Id: <36d33283.185631674@news.ionet.net>

	Use mail-lib.cgi. It works perfectly on an NT system. You'll
have to make sure that the libnet package is installed to the
activestate perl though. Thats really easy though.


On Tue, 23 Feb 1999 21:07:44 GMT, wyndo@cxo.com wrote:

>This *might* not be a Perl question, but I'm not sure where else to start.
>
>I have a large web-based multiplayer role playing game
>(http://www.lunatix-online.com) written in Perl. Originally on a UNIX-based
>system, I have a section of code that takes the new-player info and emails it
>to the new player (to give him/her a validation number) and carbon copies me.
>This was done using a Perl call to sendmail and it works fine.
>
>However, that server was only a 486/Dx2-66 and just didn't have the power to
>support a busy game with many players logged in. So, my web host (a local
>provider) moved me to a new machine which is much more powerful and supports
>the game very well. However, this new machine is on an NT system using
>ActivePerl. The only problem I have not been able to resolve is the issue of
>sending this new player letter.
>
>I have "patched" the problem by leaving a small CGI email script on the old
>server, which gets "called" (a tricky thing of using the image.src property in
>JavaScript) by a page generated on the new server. This has actually been
>working fine for the past two or three months.
>
>However, we plan to sell game licenses to other servers and anybody using NT
>is going to have this problem -- I don't want to ask them to run an
>additional UNIX server for the sole purpose of sending a new player email --
>it's fine for us, but definitely not a marketable solution.
>
>My web host was supposed to provide the answer for me, but they have not. Does
>anybody know what the equivalent of "sendmail" is for an NT system?
>
>Mike Snyder
>http://www.lunatix-online.com/ (Lunatix Online: Global Insanity Crisis)
>http://www.prowler-pro.com/logic/ (Lunatix Online Home Page)
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    



------------------------------

Date: 25 Feb 1999 17:47:08 -0500
From: tonys@myspleen.kos.net (tony summerfelt)
Subject: Re: Email from Perl on NT
Message-Id: <slrn7dbi5i.81.tonys@shark.home.ca>

On Tue, 23 Feb 1999 21:07:44 GMT, wyndo@cxo.com wrote:

> anybody know what the equivalent of "sendmail" is for an NT system?

there's a couple of different programs floating around that will do what you
want. i used one called `blat'. it did everything i wanted.

a search will turn it up quickly enough...

-- 
 .t
*-------------------------------------------------------------------------
| origin: ...the vented spleen kingston on (613-544-9332) 1:249/139 
|
| `you want a toe? i can get you a toe'
|
| take myspleen out to reply via email
*-------------------------------------


------------------------------

Date: Fri, 26 Feb 1999 12:54:01 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Email from Perl on NT
Message-Id: <36D60CC9.82C3CAC3@spider.herston.uq.edu.au>

There's always "sendmail", of course, but it's not freeware.

-- 
Jaime Metcher

tony summerfelt wrote:
> 
> On Tue, 23 Feb 1999 21:07:44 GMT, wyndo@cxo.com wrote:
> 
> > anybody know what the equivalent of "sendmail" is for an NT system?
> 
> there's a couple of different programs floating around that will do what you
> want. i used one called `blat'. it did everything i wanted.
> 
> a search will turn it up quickly enough...
> 
> --
> .t
> *-------------------------------------------------------------------------
> | origin: ...the vented spleen kingston on (613-544-9332) 1:249/139
> |
> | `you want a toe? i can get you a toe'
> |
> | take myspleen out to reply via email
> *-------------------------------------


------------------------------

Date: Mon, 22 Feb 1999 01:42:07 GMT
From: olmert@netvision.net.il
Subject: error message
Message-Id: <7aqcle$the$1@nnrp1.dejanews.com>

Hello, i have installed and used active perl for a while now. Howver, when I
try to use it CGI, I get the following error message:

HTTP Error 405

405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource
identified by the request. Please ensure that you have the proper
MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.


That is although the pl extension is associated with perl.exe (as efined in
the netscap prefences' applications dialogue), I am positive the script is a
valid one and the directory it's in has Execute permissions (and it is a
shared one). Any ideas?

please reply to both user and group.

thanks.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 22 Feb 1999 22:56:03 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: error message
Message-Id: <7asna3$3tj$1@gellyfish.btinternet.com>

On Mon, 22 Feb 1999 01:42:07 GMT olmert@netvision.net.il wrote:
> Hello, i have installed and used active perl for a while now. Howver, when I
> try to use it CGI, I get the following error message:
> 
> HTTP Error 405
> 
> 405 Method Not Allowed
> 

This is not a Perl diagnostic - it is coming from your HTTP server.

I would consult the documentation for your Server.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


------------------------------

Date: Wed, 24 Feb 1999 09:12:08 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: escaping in CSV (was Re: Converting CSV to LDIF)
Message-Id: <19990224.091208.2W3.rnr.w164w_-_@locutus.ofB.ORG>

bart.lateur@skynet.be (Bart Lateur) quotes and writes:

>> "Comma separated values".  Typically, in addition to commas
>> separating values, values may be double-quoted strings to protect
>> internal commas, and double quotes inside such strings may be
>> backslashed to protect them.
>
> Ouch. I don't think quotes are backslashed. Otherwise, you'd have to
> backslash backslashes too. Quotes are generally *doubled*.

Bart is correct.

from the comp.apps.spreadsheets FAQ:

  if a comma is needed, the entire field will be surrounded by
  quotation marks (though there is software that gets even this
  wrong -- the Windows NT 3.51 Event Log export function is one
  example).  some packages enclose any string value (and even numeric
  values) in quotation marks.  to represent a quotation mark within
  a field, double it (don't use `\"') and quote the whole field.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


------------------------------

Date: Thu, 25 Feb 1999 18:00:17 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Executing SSI from CGI Output
Message-Id: <eXvh0jOY#GA.123@nih2naae.prod2.compuserve.com>

Hi there,

I was just wondering, is there anyway to execute SSI commands when they are
printed with a CGI script?  What happens is the CGI script opens up a
template file, and prints out the file line by line.  I was just wondering
if there is anyway to include SSI in the template file, and actually have it
execute?  Or is that the server's problem?

Thanks alot,
Mike Watkins





------------------------------

Date: Thu, 25 Feb 1999 20:46:31 GMT
From: dhosek@webley.com
Subject: Re: Executing SSI from CGI Output
Message-Id: <7b4cr3$hl0$1@nnrp1.dejanews.com>

In article <eXvh0jOY#GA.123@nih2naae.prod2.compuserve.com>,
  "Mike Watkins" <mwatkins@promotion4free.com> wrote:

> I was just wondering, is there anyway to execute SSI commands when they are
> printed with a CGI script?  What happens is the CGI script opens up a
> template file, and prints out the file line by line.  I was just wondering
> if there is anyway to include SSI in the template file, and actually have it
> execute?  Or is that the server's problem?

This isn't really a perl problem, but to answer your questions, most (all?)
servers do not obey SSI directives in CGI output.

You can execute other programs from perl (perldoc -f open will tell you more)
and that should probably fulfill your needs although you may need to strip off
some http headers from the other script.

-dh


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Mon, 22 Feb 1999 11:20:50 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.13: How can I find the Julian Day?
Message-Id: <MPG.113b4deb892be441989a6a@nntp.hpl.hp.com>

In article <36d17cde@csnews> on 22 Feb 1999 08:50:54 -0700, Tom 
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, 
>     smithj@statenislandonline.com writes:
> :Can someone please tell me how to do this without the mod.
> 
> Sure -- read the source.

Or pick up this function directly from the Perl Function Repository:

http://moiraine.dimensional.com/~dgris/cgi-
bin/pfr?index=1&func=dmy_to_julian

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 22 Feb 1999 15:19:09 GMT
From: smithj@statenislandonline.com
Subject: Re: FAQ 4.13: How can I find the Julian Day?
Message-Id: <7arsh4$4u0$1@nnrp1.dejanews.com>

Can someone please tell me how to do this without the mod.


In article <36cfc241@csnews>,
  perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> (This excerpt from perlfaq4 - Data Manipulation
>     ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq4.html
> if your negligent system adminstrator has been remiss in his duties.)
>
>   How can I find the Julian Day?
>
>     Neither Date::Manip nor Date::Calc deal with Julian days. Instead, there
>     is an example of Julian date calculation that should help you in
>     http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/Julian
>     Day.pm.gz .
>
> --
> "Though a program be but three lines long,
> someday it will have to be maintained."
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 22 Feb 1999 08:50:54 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.13: How can I find the Julian Day?
Message-Id: <36d17cde@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    smithj@statenislandonline.com writes:
:Can someone please tell me how to do this without the mod.

Sure -- read the source.

--tom
-- 
        ``Imagination is more important than knowledge.''
				(A. Einstein)


------------------------------

Date: Mon, 22 Feb 1999 19:55:11 GMT
From: hans-georg@rist.net (Hans-Georg Rist)
Subject: Re: FAQ 4.13: How can I find the Julian Day?
Message-Id: <36d1b4d4.1006244@news.uni-ulm.de>

smithj@statenislandonline.com wrote:

>>   How can I find the Julian Day?
>>
>>     Neither Date::Manip nor Date::Calc deal with Julian days. Instead, there
>>     is an example of Julian date calculation that should help you in
>>     http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/Julian
>>     Day.pm.gz .

>Can someone please tell me how to do this without the mod.

Use these two functions:
(original C-source: ftp://ftp.heise.de/pub/ct/listings/ct9715.zip)


#=============================================================================
sub j_date {
#-----------------------------------------------------------------------------
# Arguments: year, month (1=Jan, 2=Feb, ... 12=Dec), day (1...31)
#   Returns: Julian date (days since 1.1.4713 B.C.)
#-----------------------------------------------------------------------------
# Algorithm: R. G. Tantzen
#-----------------------------------------------------------------------------

my( $year, $month, $day ) = @_;
my( $c, $y );

if ( $month > 2 ) {
   $month -= 3;
}
else {
   $month += 9;
   $year--;
}

$day += int( ( 153 * $month + 2 ) / 5 );
$c = int( ( 146097 * int( $year / 100 ) ) / 4 );
$y = int( ( 1461 * ( $year % 100 ) ) / 4 );
$c + $y + $day + 1721119;   # return value

} # end sub j_date()
#=============================================================================


#=============================================================================
sub g_date {
#-----------------------------------------------------------------------------
# Arguments: Julian date (days since 1.1.4713 B.C.)
#   Returns: year, month (1=Jan, 2=Feb, ... 12=Dec), day (1...31)
#-----------------------------------------------------------------------------
# Modified algorithm from R. G. Tantzen
#-----------------------------------------------------------------------------

my( $jd ) = @_;
my( $year, $month, $day );

$jd -= 1721119;

$year = int( ( 4 * $jd - 1 ) / 146097 );
$jd = ( 4 * $jd - 1 ) % 146097;
$day = int( $jd / 4 );

$jd = int( ( 4 * $day + 3 ) / 1461 );
$day = ( 4 * $day + 3 ) % 1461;
$day = int( ( $day + 4 ) / 4 );

$month = int( ( 5 * $day - 3 ) / 153 );
$day = ( 5 * $day - 3 ) % 153;
$day = int( ( $day + 5 ) / 5 );

$year = 100 * $year + $jd;
if ( $month < 10 ) {
   $month+=3;
}
else {
   $month -= 9;
   $year++;
}

( $year, $month, $day );   # return values

} # end sub g_date()
#=============================================================================


HG


-- 
Hans-Georg Rist
hans-georg@rist.net


------------------------------

Date: 21 Feb 1999 23:23:05 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: FAQ 4.20: How do I find matching/nesting anything?
Message-Id: <7aq4gp$4lp$1@towncrier.cc.monash.edu.au>

Tom Christiansen <perlfaq-suggestions@perl.com> writes:

>    ...the standard module Text::Balanced...

Err. It's certainly in the CPAN.
When did it get promoted to the standard distribution?


Damian


------------------------------

Date: 21 Feb 1999 13:51:04 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 4.26: How can I count the number of occurrences of a substring within a string?  
Message-Id: <36d071b8@csnews>

(This excerpt from perlfaq4 - Data Manipulation 
    ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq4.html
if your negligent system adminstrator has been remiss in his duties.)

  How can I count the number of occurrences of a substring within a string?

    There are a number of ways, with varying efficiency: If you want a count
    of a certain single character (X) within a string, you can use the
    `tr///' function like so:

        $string = "ThisXlineXhasXsomeXx'sXinXit";
        $count = ($string =~ tr/X//);
        print "There are $count X charcters in the string";

    This is fine if you are just looking for a single character. However, if
    you are trying to count multiple character substrings within a larger
    string, `tr///' won't work. What you can do is wrap a while() loop
    around a global pattern match. For example, let's count negative
    integers:

        $string = "-9 55 48 -2 23 -76 4 14 -44";
        while ($string =~ /-\d+/g) { $count++ }
        print "There are $count negative numbers in the string";

-- 
echo $package has manual pages available in source form.
echo "However, you don't have nroff, so they're probably useless to you."
    --Larry Wall in Configure from the perl distribution


------------------------------

Date: 21 Feb 1999 14:39:09 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 4.27: How do I capitalize all the words on one line?  
Message-Id: <36d07cfd@csnews>

(This excerpt from perlfaq4 - Data Manipulation 
    ($Revision: 1.43 $, $Date: 1999/01/26 09:57:23 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq4.html
if your negligent system adminstrator has been remiss in his duties.)

  How do I capitalize all the words on one line?

    To make the first letter of each word upper case:

            $line =~ s/\b(\w)/\U$1/g;

    This has the strange effect of turning "`don't do it'" into "`Don'T Do
    It'". Sometimes you might want this, instead (Suggested by Brian Foy):

        $string =~ s/ (
                     (^\w)    #at the beginning of the line
                       |      # or
                     (\s\w)   #preceded by whitespace
                       )
                    /\U$1/xg;
        $string =~ /([\w']+)/\u\L$1/g;

    To make the whole line upper case:

            $line = uc($line);

    To force each word to be lower case, with the first letter upper case:

            $line =~ s/(\w+)/\u\L$1/g;

    You can (and probably should) enable locale awareness of those
    characters by placing a `use locale' pragma in your program. See the
    perllocale manpage for endless details on locales.

    This is sometimes referred to as putting something into "title case",
    but that's not quite accurate. Consider the proper capitalization of the
    movie *Dr. Strangelove or: How I Learned to Stop Worrying and Love the
    Bomb*, for example.

-- 
    "Computer Science is no more about computers than astronomy 
    is about telescopes." --E.W. Dijkstra


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4966
**************************************

home help back first fref pref prev next nref lref last post