[11289] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4889 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 13 19:07:25 1999

Date: Sat, 13 Feb 99 16:00:20 -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           Sat, 13 Feb 1999     Volume: 8 Number: 4889

Today's topics:
    Re: "Learning Perl" <gellyfish@btinternet.com>
    Re: choosing start_element() vs. startElement() <gellyfish@btinternet.com>
    Re: Creating /tmp files securely? (David Efflandt)
        Defining External Interfaces <neiled@enteract.com>
    Re: displaying images in directory (David Efflandt)
    Re: General  sort question (Tad McClellan)
    Re: Graphs and gifs <ringo6@worldnet.att.net>
    Re: How do I delete a hash element ?? (Craig Berry)
        Need Perl extn to scrape data off a DOS app screen... thebeach@email.com
    Re: Need Perl extn to scrape data off a DOS app screen. ran@netgate.net
    Re: Newbie from Intel Evil Empire wants to know how to  <gellyfish@btinternet.com>
    Re: newbie: hitcounter <gellyfish@btinternet.com>
    Re: passing multiple arrays to a subroutine scraig@my-dejanews.com
    Re: Perl Criticism (Richard Clamp)
    Re: perl not always in /usr/bin/perl <ringo6@worldnet.att.net>
        Perl with PGP? <Paul@willowsoft.co.uk>
    Re: Perl, PHP, Python, ColdFusion, MS Frontpage, which  lvirden@cas.org
        Perl??? <battles@flash.net>
    Re: PFR: read_file, write_file <dgris@moiraine.dimensional.com>
    Re: PFR: UTC_to_Epoch (Larry Rosler)
    Re: Please Help a New Perl Student (John D.)
    Re: Please Help a New Perl Student <jeffp@crusoe.net>
    Re: Please Help a New Perl Student <gellyfish@btinternet.com>
    Re: Please Help a New Perl Student <allan@due.net>
    Re: Problem with file creation <gellyfish@btinternet.com>
    Re: Shell access? <gellyfish@btinternet.com>
    Re: Updating activeperl on Win95 <gellyfish@btinternet.com>
    Re: use of quote's (Daniel Norton)
    Re: x-perl what's that? (Tasslehoff Burrfoot)
    Re: x-perl what's that? (Tasslehoff Burrfoot)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 13 Feb 1999 21:31:47 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: "Learning Perl"
Message-Id: <7a4r03$4gn$1@gellyfish.btinternet.com>

On Fri, 12 Feb 1999 11:45:15 -0800 Bill Garrett wrote:
>     I got the book "Learning Perl"  and for some reason some of the
> source code doesn't work.
> I took this code exactly from the book and it doesn't work:
> #!/usr/local/bin/perl -w
> print "What is your name?";
> $name = <STDIN>;
> chomp ($name);
> print "Hello, $name!\n";
> 
> 
> What could be the problem?
> Does it only run from the shell?
> 

If by that you mean you expect it run as a CGI application then yes it
is only suitable to be run from the shell.  If you want to create a CGI
application then you will have to supply the correct headers and so forth
for it to work in that environment.  I would suggest that you consult the
CGI documentation at :

<http://hoohoo.ncsa.uiuc.edu>

and also the fine documentation that comes with the CGI.pm module.

I dont believe that there are any examples of CGI applications in
"Learning Perl".  There are good books out there that deal with this
subject however.

/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: 13 Feb 1999 22:40:06 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: choosing start_element() vs. startElement()
Message-Id: <7a4v06$4il$1@gellyfish.btinternet.com>

In comp.lang.perl.misc Ken MacLeod <ken@bitsko.slc.ut.us> wrote:
> 
> Please take a moment to think about and comment on issues of
> portability of source code and design, consistency of naming within
> the XML set of modules and the rest of Perl modules, adherence to
> standards vs. localization, and interfacing to other languages through
> things like CORBA, RPC, or other bridges.
> 

I'm not entirely sure that this is an issue - as long as the difference is
known i.e that certain schools prefer the OneBigNameWithCapitals approach
against the obviously_more_readable_underscore_seaprated_words then it 
most programmers will be able to understand and implement thee difference.
I for instance found myself unconsciously translating (in another thread)
the javascript parseInt to the Perlish parse_int.  

Of course if we get into a situation where there is a sharing of the 
namespaces (which I am not aware of at present) then perhaps we will have
to revisit this.  

A nostalgic thing comes over me regarding ICL's SCL where infact

display_library_details

and

displaylibrarydetails

became the same thing to the interpreter (as infact did DLD but thats
something else :)

/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: 13 Feb 1999 23:15:27 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Creating /tmp files securely?
Message-Id: <slrn7cc1ql.1e9.efflandt@efflandt.xnet.com>

On Thu, 11 Feb 1999 10:40:11 -0500, David Coppit <dwc3q@cs.virginia.edu> wrote:
>
>I've got a script that creates temporary files. Because the files contain
>email, I'm concerned about privacy. Now, the Unix way of creating
>temporary files is by putting them in /tmp (or where ever TMPDIR points).
>I believe this is also part of the POSIX standard.
>
>However, putting files in the /tmp directory is susceptible to symlink
>attacks, where an attacker guesses the name of the temp file, and creates
>a symlink to his own (readable) file.

How exactly does that work?  I just tried it in Linux and if I create a
a 600 file in /tmp owned by one user and symlink to it as another user, I
get "permission refused" when I try to read it as the other user.

On the other hand if you are talking CGI, most systems run the webserver
as 'nobody', so anybody can read your files, unless your scripts run suid
or your ISP is running apache with the suexec option.

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


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

Date: Sat, 13 Feb 1999 15:00:45 -0600
From: "Neil Edmondson" <neiled@enteract.com>
Subject: Defining External Interfaces
Message-Id: <7a4p7q$5qi$1@eve.enteract.com>

This code gives an error -

#########################
#!/usr/local/bin/perl -w
#
BEGIN

        unshift(@INC, "../Data");
}
use Structures::PersonalDetails 1.01;
 .
#########################

here's the error

"PersonalDetails.pm: Structures::PersonalDetails version 1.01 required--this
is only version at /web2/tr003027/cgi-bin/BasketBoard/test.pl line 40. BEGIN
failed--compilation aborted at /web2/tr003027/cgi-bin/BasketBoard/test.pl
line 40. "

whereas the following code doen't error.

#########################
#!/usr/local/bin/perl -w
#
BEGIN

        unshift(@INC, "../Data/Structures");
}
use PersonalDetails 1.01;
 .
#########################

in /Data/Structures I have the following

-rw-r--r--   1 tr003027 tr003027   10351 Feb 13 15:26 PersonalDetails.pm

which looks like

#########################
package PersonalDetails;
# Structure of data gathered for membership database
use strict;
use vars qw(@ISA @EXPORT $VERSION $Database @Gender @MemberType
                @MaritalStatus @HowManyBaskets @Lifestyle @Collectibles);

use Exporter;
$VERSION = 1.01;
@ISA = ('Exporter');
@EXPORT = qw($VERSION $Database @Gender @MemberType @MaritalStatus
                @HowManyBaskets @Lifestyle @Collectibles);
 .
 .
etc
#########################

TIA, Neil




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

Date: 13 Feb 1999 23:26:20 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: displaying images in directory
Message-Id: <slrn7cc2f3.1e9.efflandt@efflandt.xnet.com>

On Thu, 11 Feb 1999 10:29:25 -0800, dan <webmaster@macdaddyusa.com> wrote:
>is there a way to display every image in a directory on a web page?
>thanks

Yes, with CGI generated HTML.  Search www.dejanews.com or post your
question to the 'cgi' newsgroup.  I am sure someone has done that before.

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


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

Date: Sat, 13 Feb 1999 15:38:57 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: General  sort question
Message-Id: <hdr4a7.h94.ln@magna.metronet.com>

AWKYOU (corlando@NOTpop.phnx.uswest.net) wrote:

: How do I  sum the last 2 fields  by the first 3?

: in other words I want the  end report to display
: 20555  red   green      1850    450


: P.S. I intentionallly did not post my script  because I'm looking for a true
: guru's approach and did not want their mind clouded by my gibberish.


   No "enlightenment" is provided in my solution, but here it is anyway:

------------------------
#!/usr/bin/perl -w
use strict;

my(%sum1, %sum2); # a hash-of-arrays is probably better than parallel hashes

while (<DATA>) {
   my($key, $val1, $val2) = /(\S+\s+\S+\s+\S+)\s+(\S+)\s+(\S+)$/;
   $sum1{$key} += $val1;
   $sum2{$key} += $val2;
}

foreach (sort keys %sum1) {
   printf "%-20s %8d %8d\n", $_, $sum1{$_}, $sum2{$_};
}

__DATA__
20555    red    green      1000  250
4678      blue   yellow      500    10004
20555    red    green       850    200
------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 13 Feb 1999 23:31:08 GMT
From: "Michael Taylor" <ringo6@worldnet.att.net>
Subject: Re: Graphs and gifs
Message-Id: <7a51vs$69g@bgtnsc03.worldnet.att.net>

Try GNU plot man, it's freeware like all the other GNU stuff, although it's
not created by the same group.   It's very, very flexible, especially when
combined with a freeware program called ImageMagik that lets you convert the
 .pbm files to gif's, jpeg, whatever.  Not sure if it's robust enough for
everything you wanna do, but it'll come close.


Richard H wrote in message <36C1AA98.75A932A@hotmail.com>...
>Hi,
>Can anyone point me towards a graph plotting module, Im running on UNIX
>and GD/GIFgraph arent flexible enough to allow xy scatter graphs
>thanks,
>richard H




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

Date: Sat, 13 Feb 1999 21:54:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How do I delete a hash element ??
Message-Id: <qwmx2.1238$_B2.28000@newsfeed.slurp.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: > Did you search for 'delete' in the man page?
: 
: The technical term for your response is 'begging the question'.
: 
: He might have searched for 'undefine', 'remove', 'erase', 'expunge', 
: 'cancel', 'efface', or 'obliterate', and not found it.  But 'delete' 
: *would* have found it, because that's the answer.

But in this case, it was a fair question; after all, he used 'delete' in
the subject line of his query.  Asking grep the same question he asked us
would have found it. :)

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "The hills were burning, and the wind was raging; and the
       clock struck midnight in the Garden of Allah."


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

Date: 13 Feb 1999 20:24:33 GMT
From: thebeach@email.com
Subject: Need Perl extn to scrape data off a DOS app screen...
Message-Id: <36c6dea1.3886375@netnews.worldnet.att.net>

Is anyone aware of an extension that will allow me to pull data off a
DOS screen? For instance, fire up a DOS app and then pull data off the
DOS screen at an XY coord for a certain length? Any help appreciated!

th%ebeach%@em%ail.com  <-- take out the %'s and you got my addr.

THANKS!


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

Date: 13 Feb 1999 23:28:30 GMT
From: ran@netgate.net
Subject: Re: Need Perl extn to scrape data off a DOS app screen...
Message-Id: <7a51qu$h6i$1@remarQ.com>

In <36c6dea1.3886375@netnews.worldnet.att.net>, thebeach@email.com writes:
>Is anyone aware of an extension that will allow me to pull data off a
>DOS screen? For instance, fire up a DOS app and then pull data off the
>DOS screen at an XY coord for a certain length?

Win3.x and 95 might be flaky enough to let you get away with this 
purely in Perl (probably with a bit of help from a C subroutine to go 
sniffing through memory), but serious OSes won't.

What you want to do is infiltrate a "spy" into the DOS box that can
access its virtual screen memory, and pass the contents along to the
process running Perl.  This would take the form of a TSR (or maybe a
device driver,  but I don't think they have enough access to DOS 
services to pull this off easily), most likely activated via a "hot-key"
combination.  OS/2 allows DOS sessions to treat named pipes like stream 
files with almost-complete transparency,  and NT might,  also.  So,  the
scenario would look like this:

   Perl creates named pipe.
   Perl process starts DOS box with the "spy" TSR in its AUTOEXEC.
   DOS program runs to "completion".
   User presses hot-key (or Perl sends a keypress message to the DOS
      box's window).
   TSR streams screen data to the named pipe.

If you need to do this repeatedly within one run of the program,  read 
your OS's docs on pipes carefully:  I know that OS/2 will destroy a pipe
instance if the client does a regular file open/close,  instead of a 
pipe connect/disconnect.  So the server has to be written to create a 
new instance,  if needed.  I haven't used pipes on NT, so I don't know
whether it's different.

If you want to do this under Linux,  you could probably come up with 
something simpler by get the source for its DOS emulator and hacking it, 
but the above should work with most/all "closed-source" systems.

Ran





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

Date: 13 Feb 1999 23:26:04 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Newbie from Intel Evil Empire wants to know how to get started with basic Perl program
Message-Id: <7a51mc$4nd$1@gellyfish.btinternet.com>

On Thu, 11 Feb 1999 02:00:02 GMT onewierdchild@hotmail.com wrote:
> 
> I, too, am working on a Win95 box, although it's a tad bit old, (Intel 75 MHz
> Pentium, 1.2 GB, 16 MB RAM, etc., etc.)
>

Perfectly adequate for Linux ( so long as you dont try to run X :)

/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: 13 Feb 1999 20:06:53 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: newbie: hitcounter
Message-Id: <7a4m0t$4dd$1@gellyfish.btinternet.com>

On Fri, 12 Feb 1999 09:14:43 -0500 Pavel Aubuchon-Mendoza wrote:
> www.worldwidemart.com/scripts

Aaaaaargh !!!

I'm sure that you can find some better script than that if you really
must do this.

The best way of course to determine the way in which your site is
being used is by checking the server logs - this will give you a far
more accurate picture of what is going on - but of course still has
its limitations.

/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: Sat, 13 Feb 1999 23:01:58 GMT
From: scraig@my-dejanews.com
Subject: Re: passing multiple arrays to a subroutine
Message-Id: <7a5092$47b$1@nnrp1.dejanews.com>



> sub createHTML{
> 	my ($tempfile, $galleryfile, $scandir, @userfound,
> @titlefound)= @_;

> I'm sure its a simple problem, but what am I missing?

    Arrays are greedy in an assignment, that is, @userfound will gobble up all
but the first three values, leaving nothing for @titlefound.

    The standard way around this is to use references, but this can be tricky.
One approach is:

sub createHTML{
	my ($tempfile, $galleryfile, $scandir, $userfoundref, $titlefoundref)=
@_;
    my @userfound  = @$userfoundref;
    my @titlefound = @$titlefoundref;
}

when called by

createHTML($tempfile, $galleryfile, $scandir, \@userfound, \@titlefound);

Then the two arrays are copies of the arrays that were passed in.

    Another approach looks very similar, but can be dangerous.

sub createHTML{
    my ($tempfile, $galleryfile, $scandir, $userfoundref, $titlefoundref)= @_;
    my $item;

    while( $item = shift @$userfoundref ){  ## depletes original array
         print $item, "\n";
    }
}

when called the same way, changes the array that was passed in.  That is, the
array wasn't copied, a reference to it was. Changes to the array inside the
sub are still there after the sub leaves scope.

    These pitfalls of using refences are not necessarily bad.  In many
languages, such as C and Java, this is the standard way to have a subroutine
operate on an object in a lasting way. Read chapter 4 of Programming Perl for
more examples of references and how to use them.

HTH
Scott

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


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

Date: Sat, 13 Feb 1999 22:18:51 GMT
From: richardc@tw2.com (Richard Clamp)
Subject: Re: Perl Criticism
Message-Id: <36c6ec4e.2037381@news.cis.dfn.de>

On Fri, 12 Feb 1999 19:52:52 GMT, topmind@technologist.com wrote:

>In article <36c40680.5586888@news.cis.dfn.de>,
>  richardc@tw2.com (Richard Clamp) wrote:
>> On Fri, 12 Feb 1999 04:10:47 GMT, topmind@technologist.com wrote:
>>
>> >
>> >Correction: If population Y tends to abuse X, then X
>> >should not be used by population Y.
>> >
>>
>> I dunno, my (Y) car wouldn't go half as well if you took it's gearbox
>> (X) away, or stopped me using it.


>They forced seatbelts (Calif.), child carseats, internal rollbars,
>helmets (mc's), etc. on us. The reason free-for-all does not quite work
>is because the rest of society ends up paying the huge medical bills
>when beltless Cowboy Joe turns himself into drewelling Vegetable Man.

And yet there are members of the population who would happily carry
DNR orders if it allowed them to ride their motorcycles without
helmets.

>Similarly, business will want to protect themselves somewhat
>from syntax abuse that they and the maintenance programmer
>pay for in the longer run.


Well, if I take my car to a private road, thrash it to pieces, ruin
the gearbox, the engine, the tires and my nerves in the name of my
personal entertainment then where is the problem?  
The only party affected to the detriment is the owner of the car (me),
who'll have to shell out and fix the car.  Someone should stop this
practice immediately and save Paul Newman and Karl Haas all the
expense in hiring mechanics, wouldn't you agree?

Buisnesses have a reasons for going with Perl, such as productivity.
Racing teams have with going for big name drivers, such as
sponsorship.

And thought police should stay out of my way.

Richard


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

Date: 13 Feb 1999 23:27:49 GMT
From: "Michael Taylor" <ringo6@worldnet.att.net>
Subject: Re: perl not always in /usr/bin/perl
Message-Id: <7a51pl$5dl@bgtnsc03.worldnet.att.net>

You could also just create a dummy file, or symbolic link called
/usr/bin/perl that points to wherever perl really is.  That's a simple Unix
solution to the problem.


Jonathan Stowe wrote in message <7a426l$3ue$1@gellyfish.btinternet.com>...
>On Thu, 11 Feb 1999 21:56:04 GMT David Combs wrote:
>> In article <36BB51F8.42B749F4@giss.nasa.gov>,
>> Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
>>>Alan Diercks wrote:
>>>>
>>>> Is there a clever way to avoid having to edit all of my scripts to fix
>>>> the
>>>>   #!/usr/bin/perl
>>>> line at the top for each new installation?
>>>
>>>try
>>>
>>>#! /usr/bin/env perl
>>>
>>>as long as perl is somewhere in the luser's path,
>>>this will find it.
>>
>> Is the above a mistake?  What is that space before
>> the "perl" in the #! line?
>>
>No it isnt a mistake -
>
>
>ENV(1)                                                     ENV(1)
>
>
>NAME
>       env - run a program in a modified environment
>
>SYNOPSIS
>       env    [-]    [-i]    [-u   name]   [--ignore-environment]
>       [--unset=name] [--help] [--version] [name=value]...  [com-
>       mand [args...]]
>
>
>Of course I have no way of knowing whether this is portable to all Unices
>but it certainly works for Linux.
>
>/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: Sat, 13 Feb 1999 23:21:05 +0000
From: Paul Churchley <Paul@willowsoft.co.uk>
Subject: Perl with PGP?
Message-Id: <MiDXNEAhjgx2EwLV@willowsoft.demon.co.uk>

I have installed ActivePerl and PGP but I want to encrypt an email that
a Perl cgi script is sending using PGP. I can see how to do this so can
anyone help please?
-- 
Paul Churchley

Email: paul@willowsoft.co.uk
WWW:   http://www.willowsoft.co.uk


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

Date: 13 Feb 1999 23:04:46 GMT
From: lvirden@cas.org
Subject: Re: Perl, PHP, Python, ColdFusion, MS Frontpage, which one for beginner
Message-Id: <7a50ee$jc5$1@srv38s4u.cas.org>


According to  <ghill@n2.net>:
:I need to interact with all the popular databases without re-inventing the
:wheel (so to speak).

:experience, I'm trying to decide from one of the following:
:- Cold Fusion  (real high, Windows only)
:- MS FrontPage  (real high, Windows only)
:- PHP (med high, multiplatform)
:- Python (med high, multiplatform)
:- Perl (high/low, multiplatform)
:
:I do want to end up with a multiplatform product and I know that Perl will run
			    ^^^^^^^^^^^^^^^^^^^^^
Given the potential compatibility problems in MS FrontPage if you don't
exert a lot of expertise, caution, and care, I would drop that one.
I've been told that many sites avoid PHP due to security concerns.

Of the other 3, Cold Fusion is designed around getting data out of any
ODBC supported database.  It runs on Windows, Solaris, and a few other
platforms - with Linux coming soon I am told.

You may have to face one thing with ColdFusion, Perl, and Python - there
comes a point in developing with all 3 languages where either because
of performance needs, or because of the need for a specialty function, you
are going to have to also deal with C and/or C++ compilers (to
compile someone's extension, etc.).  And, if the performance or 
specialty function need is great enough, you may have to write some C
code yourself.


-- 
<URL: mailto:lvirden@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Sat, 13 Feb 1999 23:16:31 GMT
From: John <battles@flash.net>
Subject: Perl???
Message-Id: <36C5B35C.773B@flash.net>

I no nothing about perl but have been looking at many source
examples.  One thing I can't understand.  Surely perl must be compiled,
or does it just get executed like the old basic?  No where has anyone
mentioned anything about compiling the examples nor where to get a perl
compiler.  Please email an answer also.  Thanks.


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

Date: 13 Feb 1999 00:35:03 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: PFR: read_file, write_file
Message-Id: <m3pv7e4uzc.fsf@moiraine.dimensional.com>

[posted and mailed]

Uri Guttman <uri@sysarch.com> writes:

> they are so simple i didn't comment them.

I don't think I like this.  Regardless of how trivial the code
is, I'd still like to have documented what it takes as arguments,
what it returns, and any gotchas associated.

>                                             also they need to use Carp but
> that can be changed by the end user.

This I don't mind at all.  Also, to address a point in another message,
I don't have any problem with including XS code as well as `pure' perl.
As far as I'm concerned XS _is_ part of perl- it's just a different
part with different capabilities.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Fri, 12 Feb 1999 18:25:22 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <MPG.112e82704e8b1db6989a35@nntp.hpl.hp.com>

In article <MPG.112e22cdc0ca2049989a2d@nntp.hpl.hp.com> on Fri, 12 Feb 
1999 11:37:21 -0800, Larry Rosler <lr@hpl.hp.com> says...
> In article <xTZw2.2752$rs2.2589589@client.news.psi.net> on Fri, 12 Feb 
> 1999 17:52:29 GMT, Abigail <abigail@fnx.com> says...
 ...
> > Perhaps you want to 'use integer;', which would avoid the calls to
> > int() and should speed up things as well.
> 
> You may well be right.  As I said in one posting, the original was 
> Fortran that I transliterated to Perl.  I was concerned that there might 
> be intermediate quotients that were then multiplied by something, so the 
> fractional part might be significant.  I will look over each step more 
> carefully and follow your suggestion if it is correct.

Abigail is right indeed.  I tested and benchmarked with explicit 'int' 
calls and with 'use integer;'  The functions produce identical results, 
but the 'use integer;' version is about one-third faster.

I also adapted and compared the Julian Day algorithm presented yesterday 
by Gregory Snow, and the latter turned out about 10% slower than 
Abigail's suggestion.

As for Abigail's second point, about overflowing 31 bits, I have found 
that 'print' assumes that integers are signed.  But if one uses 'printf 
"%u"' one can see the huge unsigned result for dates after 2038.

So here is the revised version.  I still don't understand the arithmetic 
in detail.  Take it away, dgris!

*********************************************************************

#!/usr/local/bin/perl -w
use strict;

# UTC_to_Epoch: Convert UTC date/time to Unix-epoch time.
# Larry Rosler, 12 February, 1999

# UTC_to_Epoch converts a broken-down date/time array from UTC to time
# in seconds since the Unix Epoch (midnight on 1 January, 1970).  It is
# essentially the inverse of gmtime.

# The input is a list of at least three integers:
#   year   [1970 to 2099]
#   month  [1 to 12]
#   day    [1 to whatever is appropriate for the year and month]
#   hour   [0 to 23; 0 if omitted]
#   minute [0 to 59; 0 if omitted]
#   second [0 to 59; 0 if omitted]
# 'undef' is returned if the arguments do not represent a valid
# date/time on or after the Unix Epoch.

sub UTC_to_Epoch {
    use integer;
    my ($year, $mon, $day, $hour, $min, $sec) = @_;
    defined $year && defined $mon && defined $day      or return;
    my @m_day = (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    $m_day[2] = 29 unless $year % 4; # OK from 1901 through 2099.

    1970 <= $year         && $year <= 2099
    && 1 <= $mon          && $mon  <= 12
    && 1 <= $day          && $day  <= $m_day[$mon]
    && 0 <= ($hour ||= 0) && $hour <= 23
    && 0 <= ($min  ||= 0) && $min  <= 59
    && 0 <= ($sec  ||= 0) && $sec  <= 59               or return;

    # Adapted from Astronomical Computing, Sky & Telescope, May, 1984.
    24 * 60 * 60 * (367 * $year - 678972 - 40587 + 275 * $mon / 9 -
        ((($year + ($mon < 9 ? -1 : 1) * abs($mon - 9) / 7) / 100) + 1) *
        3 / 4 - 7 * (($mon + 9) / 12 + $year) / 4 + $day) +
        60 * 60 * $hour + 60 * $min + $sec
}
    
-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 13 Feb 1999 15:04:42 -0500
From: "Dudley (John D.)" <noEmal@noPlace.com>
Subject: Re: Please Help a New Perl Student
Message-Id: <sUkx2.331$y51.12@dustdevil.neo.rr.com>

Well, you should learn to just pull up notepad, the html coders and a few of
the shell writers that I have used are worthless and it was easier for me to
just write it with a simple text program.

save the program as first.pl

on the server make sure that you make it executable.  CGI stands for Common
Gateway Interface, this interface could be perl, C, tcl, whatever., The
files are commonly put in a cgi-bin directory and chmod 755 first.pl or
however your server is setup to execute the file through the web-server.

The web server takes the stdio and posts it to the browser, that is why you
have to code the output for the browser, etc.

Goto Borders and read chapter 19 of the book Perl 5 by example, Que puts it
out with ISBN: 0-7897-0866-3

This will explain all the CGI basics on a quick and easy to read level,
John



William M. Toohey <ceo@mptenterprises.com> wrote in message
news:36c5d406.0@208.148.50.4...
>I am teaching myself to write CGI's in Perl from an otherwise great book.
I
>know this is an elementary question, but without this piece of information,
>I can do nothing.
>
>Simply, I know Perl is a free language, but where do I type in the perl
code
>and how do I save it?
>
>I code HTML in MS Word and save as text only with a .htm extension.
>I code C++ in a compiler and compile and link the code.
>What is the equivelant in Perl?
>
>I tried writing the Perl Code in Word (named "first"), saving as text only
>with a .cgi extention.
>When I uploaded this to my server, it ended up being labeled
"first.cgi.txt"
>If I can only get over this bump, the rest of the book seems well written,
>and the language itself seems rather easy for me to learn.  It just seems
>that everyone forgot to include this basic instruction.
>
>Thanking you all ahead of time for responses.
>
>I am at ceo@mptenterprises.com
>
>William M. Toohey
>
>



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

Date: Sat, 13 Feb 1999 15:19:16 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Please Help a New Perl Student
Message-Id: <Pine.GSO.3.96.990213151750.10971A-100000@crusoe.crusoe.net>

> Goto Borders and read chapter 19 of the book Perl 5 by example, Que puts it
> out with ISBN: 0-7897-0866-3

Personally, I suggest getting "Learning Perl" 2nd edition, by O'Reilly.
It not only offers a start in programming in Perl, but has a chapter about
writing Perl programs that deal with the Common Gateway Interface.

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

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



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

Date: 13 Feb 1999 20:30:23 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Please Help a New Perl Student
Message-Id: <7a4ncv$4dk$1@gellyfish.btinternet.com>

On Sat, 13 Feb 1999 14:33:00 -0500 William M. Toohey wrote:
> 
> Simply, I know Perl is a free language, but where do I type in the perl code
> and how do I save it?
> 

You can use any text-editor you like - notepad or the DOS edit will work
but you might want to avail yourself of something a little more useful
for programming work - in order to avoid the inevitable ridiculous
debate over peoples favourite editors I would suggest that you look at

 <http://reference.perl.com/query.cgi?editors>

Everyone has their own preference over editors but the thing is to find
one that works for you.

/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: Sat, 13 Feb 1999 16:17:29 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Please Help a New Perl Student
Message-Id: <s_lx2.1042$L1.23305@nntp1.nac.net>

William M. Toohey wrote in message <36c5d406.0@208.148.50.4>...
:I am teaching myself to write CGI's in Perl from an otherwise great book.  I
:know this is an elementary question, but without this piece of information,
:I can do nothing.
:Simply, I know Perl is a free language, but where do I type in the perl code
:and how do I save it?
:I code HTML in MS Word and save as text only with a .htm extension.
:I code C++ in a compiler and compile and link the code.
:What is the equivelant in Perl?
:I tried writing the Perl Code in Word (named "first"), saving as text only
:with a .cgi extention.
:When I uploaded this to my server, it ended up being labeled "first.cgi.txt"


The other folks covered the major points but just for completeness sake if you
want to save the file using NotePad, WordPad, or Word you need to force the
extension.  The easiest way is to use quotes when you save the file.  If you
just save it as a text only file filename.cgi  the above will interpret that
to mean you want a file name filename.cgi.txt.  Instead save the file as
"filename.cgi".  The quotes instruct the above programs to use the literal
name enclosed within the quotes and the file will only be saved as
filename.cgi.

HTH

AmD

[posted and emailed]





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

Date: 13 Feb 1999 21:50:43 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Problem with file creation
Message-Id: <7a4s3j$4gr$1@gellyfish.btinternet.com>

On Fri, 12 Feb 1999 00:42:42 +1100 Patrick Fong wrote:
> 
> As you can see with my subject .. I have trouble creating a file using
> HTML. 
> 
> here is my tragic situation  ...

Tragic ? Now I would call the situation of King Lear or that of Oedipus
tragic but not that of some poor newbie programmer struggling with some
simple CGI program.

Get a grip man go and have a few beers, watch 'Love Story', read some
Shakespeare.  Programming by its nature cannot encompass tragedy although
of course some of the Greek dramatists averred that hubris was the first
seed of tragedy ...

/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: 13 Feb 1999 20:47:04 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Shell access?
Message-Id: <7a4oc8$4dq$1@gellyfish.btinternet.com>

On 13 Feb 1999 09:07:31 -0500 Jonathan Feinberg wrote:
> 
> I looked at your headers, and it *seems* you're running Windows 3.1,
> so you're out of luck as far as running running Perl under your
> current OS goes. 
>

Actually you can get a port of Perl that *will* run there and it is at
the lastest stable version - this is the djgpp port available via:

<http://wwww.delorie.com/>

I havent downloaded it myself but if the previous versions of this port
are anything to go by it is very useable but might lack certain feature
such as networking and so on but there you go.

If you must you can even run an HTTP server on Windows 3.1 (whttpd)
but I'm not sure if you can do Perl CGI easily with that because of the
funny way in which the query string is passed.

/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: 13 Feb 1999 22:00:42 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Updating activeperl on Win95
Message-Id: <7a4sma$4ih$1@gellyfish.btinternet.com>

On Thu, 11 Feb 1999 04:12:38 GMT ANK wrote:
> Hi,  The latest version of perl on activeperl site is on based perl 5.005 I
> have perl 5.00307. When I try to update, it says "1 file copied, nothing to
> do.." Why it's doing like this, I have no idea, I am stuck with the old
> version and cannot use LWP Any help is appriciated..

I would suggest deleting the directory that your existing installation
is unger before doing the installation - also if you are using ISAPI
Perl then you should stop your web server as well.

/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: Sat, 13 Feb 1999 20:43:39 GMT
From: Daniel@DanielNorton.net (Daniel Norton)
Subject: Re: use of quote's
Message-Id: <36c8e328.270012367@enews.newsguy.com>

On Sat, 13 Feb 1999 09:18:58 -0000, "John Corbin" <jcorbin@apci.net>
wrote:
>I am using a MySql database and would like to pass in values to my Select
>statements. How do I get the single quotes around the values?? '$myvar'

e.g.:

 $dbh->do("SELECT * FROM table WHERE field = " . $dbh->quote($myvar)) ;


(This also introduces escape (\) sequences where needed.)


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

Date: Sat, 13 Feb 1999 19:59:07 GMT
From: tasslehoff@vt.extract.edu (Tasslehoff Burrfoot)
Subject: Re: x-perl what's that?
Message-Id: <36c5d861.84205859@news.vt.edu>

I am having the exact ame problem with some scripts I have written,
They work fine when viewed from IE4 but Navigator complains that "You
have started to download a file of type application/x-perl"

I would really appreciate any help I can get on this.

Thanks,
Brian Alexander

BTW: remove the extract from my email address to respond.


On Fri, 12 Feb 1999 17:53:52 GMT, syarbrou@nospam.enteract.com (Steve
 .) wrote:

>I recently was given a perl program to play with from an outside
>source, and when I pull it up in my browser, Netscape  3 shows it is
>an x-perl app and doesn't know what to do with it.  Any ideas on what
>I need to look for to figure out what to change to avoid this?  If you
>run the program from the command line it just shows:
>
>Content-type: text/html
>
>Which is rather normal.  Thanks.
>
>Steve



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

Date: Sat, 13 Feb 1999 21:43:05 GMT
From: tasslehoff@vt.extract.edu (Tasslehoff Burrfoot)
Subject: Re: x-perl what's that?
Message-Id: <36c5f0e2.90478218@news.vt.edu>

Okay - I found it.  At least I found what was wrong on my machine. The
registry information was not set up correctly.
System/CurrentControlSet/Services/W3SVC/Parameters/ScriptMap needed a
REG_SZ value named .pl and with a string of "C:\Perl\bin\perlis.dll".

I never was able to get perl.exe to work with IIS.  Perlis is supposed
to be faster so I guess I don't care.  I am just glad the thing works!

Happy hunting.

Brian


On Fri, 12 Feb 1999 17:53:52 GMT, syarbrou@nospam.enteract.com (Steve
 .) wrote:

>I recently was given a perl program to play with from an outside
>source, and when I pull it up in my browser, Netscape  3 shows it is
>an x-perl app and doesn't know what to do with it.  Any ideas on what
>I need to look for to figure out what to change to avoid this?  If you
>run the program from the command line it just shows:
>
>Content-type: text/html
>
>Which is rather normal.  Thanks.
>
>Steve



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

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 4889
**************************************

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