[7623] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1249 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 30 12:14:42 1997

Date: Thu, 30 Oct 97 09:00:38 -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           Thu, 30 Oct 1997     Volume: 8 Number: 1249

Today's topics:
     2038 problem, was Re: Year2000 problem with localtime() <flavell@mail.cern.ch>
     Re: 2038 problem, was Re: Year2000 problem with localti <gnat@prometheus.frii.com>
     Re: AUTOLOAD and sort (Andrew M. Langmead)
     Re: CGI script results to email? <chris_braiotta@harvard.edu>
     Re: CGI script results to email? (Neil Anuskiewicz)
     CGI/Perl Programmer For Hire <chunhoh@pc.jaring.my>
     Re: crypt on NT (Brian Wheeler)
     Eval and use proplem <k.mueller@intershop.de>
     fetch url data <webadmin@prestel.net>
     Re: fetch url data (Shawn Wagner)
     Re: fetch url data <rootbeer@teleport.com>
     Re: Help !!! (reading directory) <eike.grote@theo.phy.uni-bayreuth.de>
     Help !!! <nl65@dial.pipex.com>
     Re: Help !!! (Mike Stok)
     Re: Help !!! (Casper K. Clausen)
     Re: Help !!! <blintz@com.nicorinc>
     Re: how do I save an array into a file? (Sylvain Juneau)
     Re: how do I save an array into a file? (Andrew M. Langmead)
     how to get a program name ($0 etc.) <senger@EBI.ac.uk>
     Re: how to get a program name ($0 etc.) <rootbeer@teleport.com>
     Re: Http header and filename <per@beining.dk>
     Re: In-Line images and perl <blintz@com.nicorinc>
     Re: JavaScript document.write from Perl script <rootbeer@teleport.com>
     Re: Learning Perl <rootbeer@teleport.com>
     Re: Learning Perl <rootbeer@teleport.com>
     Re: perl and gifs or ftp <rootbeer@teleport.com>
     Re: Perl module for system-independent "stty raw"? (Keith Willis)
     Reading a Binary file. (Chad Edwards)
     Re: Reading a Binary file. (Tom Grydeland)
     Re: Reading a Binary file. (Honza Pazdziora)
     Registering a service? (Robert Parkin)
     Re: using -s to get file size (Lack Mr G M)
     Re: using -s to get file size <blintz@com.nicorinc>
     Re: Year2000 problem with localtime(); (Peter Samuelson)
     Re: Year2000 problem with localtime(); <HARTLEH1@westatNOSPAM.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 30 Oct 1997 11:09:19 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: 2038 problem, was Re: Year2000 problem with localtime();
Message-Id: <Pine.A41.3.95a.971030120223.22904F-100000@sp052>


I really didn't know what to do with the Subject - it's infuriating
to see "Year2000 problem" over and over when in fact there isn't one!
I was tempted to change it to "Year2000 non-problem"...

On Wed, 29 Oct 1997, John Moreno wrote:

> Well, using MacPerl 2038 is fine but there is a problem with 2040 - in
> any case we have 40+ years to deal with the problem and most systems are
> beginning to go to a 64 bit system, this will probably be complete
> within 15 years.

But that assumes that people only want to compute dates beyond 2038 
when we get there.  That seems to me an unreasonable assumption, in
general.  Consider, for example, people starting their first job now,
and doing calculations relating to their pension entitlement.




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

Date: 30 Oct 1997 09:27:58 -0700
From: Nathan Torkington <gnat@prometheus.frii.com>
Subject: Re: 2038 problem, was Re: Year2000 problem with localtime();
Message-Id: <5q90vbi5bl.fsf@prometheus.frii.com>

"Alan J. Flavell" <flavell@mail.cern.ch> writes:
> But that assumes that people only want to compute dates beyond 2038 
> when we get there.  That seems to me an unreasonable assumption, in
> general.  Consider, for example, people starting their first job now,
> and doing calculations relating to their pension entitlement.

It's no different from any other situation where you run up against
the limitations of a datatype.  Switch to a different datatype, or
change representations.  There are modules on CPAN which will let you
work with your pension entitlements until 9999 AD (in the case of
Date::Manip) simply by changing the representation of the dates.

Nat


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

Date: Thu, 30 Oct 1997 14:36:29 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: AUTOLOAD and sort
Message-Id: <EIvCKt.DEx@world.std.com>

lmegliol@inertia.acs.uci.edu (Leonard Megliola) writes:

>I have a program which makes a call to sort such as the
>following:

>  sort _sort_subroutine ... ;

>_sort_subroutine is an AutoLoaded routine, and because "the normal
>calling code for subroutines [used in sort] is bypassed", the 
>_sort_subroutine is not loaded.  An error is printed that 
>explains that the routine cannot be found.

One way around it that I can think of is to give sort a bare code
block that calls your autoloaded sub.

@sorted = sort { _sort_subroutine() } @list;

You will pay a small performance penalty for the extra subroutine
call.
-- 
Andrew Langmead


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

Date: Thu, 30 Oct 1997 10:30:25 -0500
From: Chris Braiotta <chris_braiotta@harvard.edu>
Subject: Re: CGI script results to email?
Message-Id: <3458A810.5612CBEE@harvard.edu>



Neil Anuskiewicz wrote:

> <snip>

> I need to write a cgi script that creates a form on our web site that

> someone can fill out, submit, and then the results sent in an email. The
> email goes to several people so it must retain an easily readable
> format:

<snip>

You didn't mention what OS you're running on. It's easy in UNIX, not so
easy on mac...

Chris Braiotta
chris_braiotta@harvard.edu




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

Date: 30 Oct 97 16:40:50 GMT
From: neil@pacifier.com (Neil Anuskiewicz)
Subject: Re: CGI script results to email?
Message-Id: <3458b892.0@news.pacifier.com>


UNIX server




Chris Braiotta (chris_braiotta@harvard.edu) wrote:
: 
: 
: Neil Anuskiewicz wrote:
: 
: > <snip>
: 
: > I need to write a cgi script that creates a form on our web site that
: 
: > someone can fill out, submit, and then the results sent in an email. The
: > email goes to several people so it must retain an easily readable
: > format:
: 
: <snip>
: 
: You didn't mention what OS you're running on. It's easy in UNIX, not so
: easy on mac...
: 
: Chris Braiotta
: chris_braiotta@harvard.edu
: 
: 


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

Date: Thu, 30 Oct 1997 17:50:18 +0800
From: "Chun-Hoh, KOH" <chunhoh@pc.jaring.my>
Subject: CGI/Perl Programmer For Hire
Message-Id: <34585859.E8EEB6B@pc.jaring.my>

Dear sir/madam,

I am a Internet CGI/Perl programmer. I am still studying and as this is
my holidays, I'd like to take the opportunity to earn some pocket money
so that I can afford more books to enhance my knowledge. I'd like to
know if anyone's interested in hiring a part-time CGI/Perl programmer.

I have designed many applications for companies in various countries. My
programmes cover a wide range of functionality. Among the ones I've
designed includes jobs/ads database system, resume management, secure
free home page accounts system, chats, guestbooks, bulletin boards, user
tracking utility, search engines, and also inter-server communication
scripts which extracts information from various sites.

I am familiar with both Unix and Windows NT system. I have fair
knowledge of SQL, HTML, Java, Javascript, C++, Turbo Pascal, but I am
most familiar with PERL.

I really hope to be able to find a part-time holiday job to fund myself
so that I can enhance and improve myself.

I can be contacted at the following email addresses :
chunhoh@pc.jaring.my (preferred)
chunhoh@abds.net
chunhoh@dezine.net
chunhoh@jobsmalaysia.com

Thank you very much.
Chun-Hoh, KOH



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

Date: 30 Oct 1997 14:00:45 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: crypt on NT
Message-Id: <63a3ud$rcb$1@dismay.ucs.indiana.edu>

In article <6392dk$fd5$1@lennon.postino.com>,
	danny@lennon.postino.com (Danny Aldham) writes:
> Brian Wheeler (bdwheele@indiana.edu) wrote:
>: How do I get the crypt function to work on NT?  I'm using the 5.00402 binary
>: distribution.
> 
> I am using the 5.003_07 binary from www.activestate.com , and crypt 
> seems to work for me.

	I'd rather use the 'official' version, if at all possible.  Any other
solutions, short of re-implementing crypt myself?


> 
> --
> Danny Aldham           SCO Ace , MCSE , JAPH , DAD
> I wak'd, she fled, and day brought back my night. jm


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

Date: Thu, 30 Oct 1997 17:00:23 +0100
From: Klaus Mueller <k.mueller@intershop.de>
Subject: Eval and use proplem
Message-Id: <3458AF17.F1D52A59@intershop.de>

Hello,

I have a problem using "eval" and "use" together.

First a small code example:
Script (extract):
---
$a = "use Test; Test()";
eval $a;
warn $@ if $@;
---
Test.pm:
---
package Test;
require 5.001;
require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw(Test);

sub Test {
  print "Hallo\n";
}

1;
---
The script is running within a long living process. It's executed on a
special condition.
The first time it's printing "Hallo". Sometime later I change the
Test.pm module (print "Hallo 2\n";). But the next time the script is
executed it also print "Hallo" and not "Hallo 2" as expected.

Question: How to reload a module after a change using "use"?

Thanks
Klaus


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

Date: Thu, 30 Oct 1997 15:55:33 +0000
From: webadmin <webadmin@prestel.net>
Subject: fetch url data
Message-Id: <3458ADF5.9625D8E1@prestel.net>

Hi

I would like to go to a particular web page from a cron job, and retrive
the data, and place it into a file.

Is this possible, and does anyone have any pointers. I presume I would
be telnetting to port 80, and sending through the get headers or
something.

Thanks Iqbal


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

Date: 30 Oct 1997 11:43:09 -0500
From: shawnw@bigwpi.WPI.EDU (Shawn Wagner)
Subject: Re: fetch url data
Message-Id: <63adet$2mk$1@bigwpi.WPI.EDU>

In article <3458ADF5.9625D8E1@prestel.net>,
webadmin  <webadmin@prestel.net> wrote:
>Hi
>
>I would like to go to a particular web page from a cron job, and retrive
>the data, and place it into a file.
This has nothing to do with perl, so really should have gone to a 
different newsgroup.

It can be done with perl, true. It can also be done with a number of
other programs (Hint: 'man -k web' listed a few on the system I use).

But unless your questions have something specific to do with perl,
please ask them elsewhere.


-- 
Shawn Wagner - shawnw@wpi.edu
http://mycroft.res.wpi.net/shawnw/
Narf!


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

Date: Thu, 30 Oct 1997 08:54:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: webadmin <webadmin@prestel.net>
Subject: Re: fetch url data
Message-Id: <Pine.GSO.3.96.971030085437.28125S-100000@usertest.teleport.com>

On Thu, 30 Oct 1997, webadmin wrote:

> I would like to go to a particular web page from a cron job, and retrive
> the data, and place it into a file.

Use LWP, which you can find on CPAN. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 17:10:27 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Help !!! (reading directory)
Message-Id: <3458B173.446B@theo.phy.uni-bayreuth.de>

Hi,

Lee Cullip wrote:
> 
> Could somebody tell me why I only get the last file in $DBADIR appearing
> in my logfile ?
> Being a newby perl programmer, it has got me stumped.

There are several things to metion - let's take a look at the code ...

> ----------------------------------------
> use Win32;
> 
> # Variable Declarations
> $HOMEDIR='C:\LJC';
> $DBADIR='C:\LJC\DBA';
> 
> # Program Start
> chdir $HOMEDIR;
> opendir (DBADIR,$DBADIR) || die "Could not open Directory $DBADIR : $!";
> 

code above looks quite fine  :-)

> LIST: while ($FILE=readdir(DBADIR)) {
>  open (STDOUT,'>dirlist.txt');
>  print STDOUT "$FILE\n";
>  next LIST;
> }
> close STDOUT;

1) Why do you use the label LIST ? Just let the 'while' loop run ...
2) Every time you step through the loop you 'open' your file again
   which is obviously a bad thing.
3) I don't think that it is wise to call a file handle 'STDOUT';
   if you insist on doing this you don't have to say it again at
   the 'print' command.
4) You should check if '$FILE' gets undef-ined some time (it will
   at the end of the directory).

My suggestion for a better solution would be:

  open(OUTFILE,'>dirlist.txt') or die "Cannot open: $!\n";
  while( defined($FILE = readdir(DBADIR) ) ) {
      print OUTFILE "$FILE\n";
  }
  close OUTFILE or die "Cannot close: $!\n";
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
                     yes, this can happen, too ...


Bye, Eike

P.S.: "Help !!!" isn't a good subject at all ...
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: Thu, 30 Oct 1997 15:15:02 +0000
From: Lee Cullip <nl65@dial.pipex.com>
Subject: Help !!!
Message-Id: <3458A475.B00350F7@dial.pipex.com>

Could somebody tell me why I only get the last file in $DBADIR appearing
in my logfile ?
Being a newby perl programmer, it has got me stumped.

Regards
Lee
----------------------------------------
use Win32;

# Variable Declarations
$HOMEDIR='C:\LJC';
$DBADIR='C:\LJC\DBA';

# Program Start
chdir $HOMEDIR;
opendir (DBADIR,$DBADIR) || die "Could not open Directory $DBADIR : $!";

LIST: while ($FILE=readdir(DBADIR)) {
 open (STDOUT,'>dirlist.txt');
 print STDOUT "$FILE\n";
 next LIST;
}
close STDOUT;



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

Date: 30 Oct 1997 15:54:28 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Help !!!
Message-Id: <63aajk$m51@news-central.tiac.net>

In article <3458A475.B00350F7@dial.pipex.com>,
Lee Cullip  <nl65@dial.pipex.com> wrote:
>Could somebody tell me why I only get the last file in $DBADIR appearing
>in my logfile ?
>Being a newby perl programmer, it has got me stumped.
>
>Regards
>Lee
>----------------------------------------
>use Win32;
>
># Variable Declarations
>$HOMEDIR='C:\LJC';
>$DBADIR='C:\LJC\DBA';
>
># Program Start
>chdir $HOMEDIR;
>opendir (DBADIR,$DBADIR) || die "Could not open Directory $DBADIR : $!";
>
>LIST: while ($FILE=readdir(DBADIR)) {
> open (STDOUT,'>dirlist.txt');

This re-opens dirlist.txt every time you go around the loop, and if you
chek the perlfunc man page it says:

               If the filename begins with '<' or nothing, the
               file is opened for input.  If the filename begins
               with '>', the file is truncated and opened for
               output.  If the filename begins with '>>', the
               file is opened for appending. 

so each time around you truncate the file and write the next directory
entry into it.

> print STDOUT "$FILE\n";
> next LIST;
>}
>close STDOUT;


You might want to say something like:

  open (DIRLIST, ">dirlist.txt") || die "$0: couldn't open dirlist ($!)\n";
  while (defined ($entry = readdir (DBADIR))) {
    print DIRLIST "$entry\n";
  }
  close (DIRLIST) || warn "$0: odd close on dirlist ($!)\n";

(untested code warning, I hope you get the drift...)

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 30 Oct 1997 16:53:52 +0100
From: ckc@dmi.min.dk (Casper K. Clausen)
Subject: Re: Help !!!
Message-Id: <wvp4t5zb627.fsf@hobbes.dmi.min.dk>

>>>>> "L" == Lee Cullip <nl65@dial.pipex.com> writes:

L> Could somebody tell me why I only get the last file in $DBADIR appearing
L> in my logfile ?

Certainly.

L> LIST: while ($FILE=readdir(DBADIR)) {
L>  open (STDOUT,'>dirlist.txt');
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
L>  print STDOUT "$FILE\n";
L>  next LIST;
L> }
L> close STDOUT;

You open it for each iteration of the loop. When you open a file for
input, you delete any prior content. Move the open statement somewhere
outside the loop.

Kvan.
-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


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

Date: Thu, 30 Oct 1997 10:32:49 -0600
From: Brian Lintz <blintz@com.nicorinc>
Subject: Re: Help !!!
Message-Id: <3458B6B1.BE0@com.nicorinc>

Lee Cullip wrote:
> Could somebody tell me why I only get the last file in $DBADIR appearing
> in my logfile ?
> Being a newby perl programmer, it has got me stumped.
>[...]
> LIST: while ($FILE=readdir(DBADIR)) {
>  open (STDOUT,'>dirlist.txt');
>  print STDOUT "$FILE\n";
>  next LIST;
> }
> close STDOUT;

cuz you re-open the output file (thus removing its current contents)
every time your while loop, loops. :)

if you move the "open(STDOUT,'>dirlist.txt');" line above the while
you should be okay ...

-- 
Brian Lintz
WebMaster - Nicor Gas, Inc.


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

Date: Thu, 30 Oct 1997 14:23:35 GMT
From: sylvain.juneau@ec.gc.ca (Sylvain Juneau)
Subject: Re: how do I save an array into a file?
Message-Id: <345897b2.67419671@news.cmc.ec.gc.ca>

I would like to thank you for the overwhelming response to my post.
This is the first time for me on the newsgroup and I am very inpressed
by it.


THANK YOU / MERCI BEAUCOUP

On Wed, 29 Oct 1997 19:55:12 GMT, sylvain.juneau@ec.gc.ca (Sylvain
Juneau) wrote:

>how do I save an array into a file?



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

Date: Thu, 30 Oct 1997 14:44:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: how do I save an array into a file?
Message-Id: <EIvCyG.JBC@world.std.com>

Doug Seay <seay@absyss.fr> writes:

>Doug Seay wrote:

>>         print FILE join("\n", @array);

>Sorry to followup my own post, but,that doesn't put a \n after the last
>element.  That should have been

And if the last element of @array is 0, then you make a data file that
will trip the bug in:

    while($line = <FILE>) 

Don't you love the way perl's features fit togther?
-- 
Andrew Langmead


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

Date: Thu, 30 Oct 1997 13:20:54 +0000
From: Martin Senger <senger@EBI.ac.uk>
Subject: how to get a program name ($0 etc.)
Message-Id: <345889B5.60B9A172@EBI.ac.uk>

I need to get a full name of a running Perl program. Usually I get it
from $0. But it does not work always:

1) I had a problem with a Perl script started as a cronjob with a name
like: /home/name/prg/script.pl
when /home/name is a symbolic link to /foo/home/name. When I named the
script in the crontab without using symbolic link
/foo/home/name/prg/script.pl, $0 gave again a correct full name.

2) Recently one my user reported that $0 in a CGI script returns a very
strange result: /dev/fd/3.

My question is, and I would very appreciate any help, how to get a
program name, either from $0 but always correctly, or by some other way.

Thanks and regards,
Martin

---
Martin Senger

EMBL Outstation - Hinxton                Senger@EBI.ac.uk
European Bioinformatics Institute        Phone: (+44) 1223 494636
Wellcome Trust Genome Campus             (Switchboard:     494444)
Hinxton                                  Fax  : (+44) 1223 494468
Cambridge CB10 1SD
United Kingdom
http://industry.ebi.ac.uk/~senger




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

Date: Thu, 30 Oct 1997 08:40:39 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Martin Senger <senger@EBI.ac.uk>
Subject: Re: how to get a program name ($0 etc.)
Message-Id: <Pine.GSO.3.96.971030082646.28125P-100000@usertest.teleport.com>

On Thu, 30 Oct 1997, Martin Senger wrote:

> I need to get a full name of a running Perl program. 

(I think that by "full name" you mean what I'd call the "fully-qualified
path name".) In general, you can't do that. But you can sometimes come
close. :-) 

> Usually I get it from $0. But it does not work always: 
> 
> 1) I had a problem with a Perl script started as a cronjob with a name
> like: /home/name/prg/script.pl
> when /home/name is a symbolic link to /foo/home/name. When I named the
> script in the crontab without using symbolic link
> /foo/home/name/prg/script.pl, $0 gave again a correct full name.

$0 is what Perl thinks is the full name of the script. In that case, the
symlink is the nearest thing to the full name which Perl has. (If you want
to do so, you could use readlink to see where the symlink points. Be sure 
to repeat as needed - you may have a symlink to a symlink to a script.) 

> 2) Recently one my user reported that $0 in a CGI script returns a very
> strange result: /dev/fd/3. 

That's what some systems use to allow set-id scripts to be secure. The
good news is that this accomplishes its goal - it keeps someone from
fooling the system into running their scripts under your id. The bad news
is that, once your script is running, you can't tell where the original
text came from. (Unless, of course, you do something rude like peek into
the kernel's data scructures. :-)

What's the solution? That depends upon what you're really trying to
accomplish. Do you want to be able to generate a diagnostic message which
tells just which script was running? If so, $0 is about as good as it
gets. 

If you want a dependable name for the script, you could do something like
this near the top of your script:

    # Update these as needed!
    use constant SCRIPT_NAME	=> 'nifty_program';
    use constant SCRIPT_PATH	=> '/home/foo/bar/' . SCRIPT_NAME ;
    use constant SCRIPT_VERSION	=> '1.03 beta';

If you want something else, post again and we'll see what we can do for
you. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: Thu, 30 Oct 1997 15:29:36 +0100
From: Per Beining <per@beining.dk>
To: Per Beining <per@beining.dk>
Subject: Re: Http header and filename
Message-Id: <345899CF.23D26DAE@beining.dk>

A friendly person told me that the subject of this message is not an
issue for the
comp.lang.perl.misc - newsgroup, but instead belongs in the
comp.infosystems.www.authoring.cgi - newsgroup.

Therefore I apollogize for the wrong posted mail (by sending another one
;-) )

If anyone wondered what the solution to my problem is, then the source
listing must look as the following:


>  My download.cgi (Perl-script) look's simplified like this:
>                       $filetype = "image/gif";
>                       print "Content-type: $filetype\n";

                         print "Content-Disposition:
filename=\"foo.gif\"\n\n";

>                       open (FILE, "$fileid.fil")
>                       while (FILE){
>                       print;
>                       }
>                       close (FILE);

Per Beining



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

Date: Thu, 30 Oct 1997 10:10:57 -0600
From: Brian Lintz <blintz@com.nicorinc>
Subject: Re: In-Line images and perl
Message-Id: <3458B191.14D@com.nicorinc>

> >Brian Lintz  <blintz@com.nicorinc> wrote:
> >> Trouble is, when you're already sending out a content type of image/gif,
> >> the user won't be able to read what the die message was... ya know?
 
brian d foy wrote:
> don't send the content type until you know you have the content!

Right, but, if they're calling this script from a web page that's 
looking for an image, it really needs to be an image that comes out.
You can't send text out to the page at that point.... if you do, it'll
just show up as a broken image, which it would've had the file not 
opened properly in the first place...

The "open another image instead" option actually is a really good 
idea... cuz then at least the person would see something that would 
let them know the intended file hadn't been opened...
 
> or you could just embed the broken image GIF data under DATA so it
> looks like you've written really long and robust script.  (maybe
> programmers should be paid by the byte)

hehe, just include the image in the script itself?

$gif = 'GIF89ajflkwjaefjwkjflkwjlfkajlwkjfwelkfjawklejf';  :)


-- 
Brian Lintz
Webmaster - Nicor Gas, Inc.


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

Date: Thu, 30 Oct 1997 08:17:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Morrison <mmorrison@vnet.ibm.com>
Subject: Re: JavaScript document.write from Perl script
Message-Id: <Pine.GSO.3.96.971030081555.28125M-100000@usertest.teleport.com>

On 30 Oct 1997, Michael Morrison wrote:

> I've been trying to issue JavaScript document.write() statements from a
> Perl script, but without success. Can it be done?  If so how? 

To Perl, any JavaScript statements are just data - strings, in particular. 
To output a string, use print. If you can't get print to do what you want,
see if you can make a small script (say, five lines) which shows the
problem. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 08:08:31 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Danny Aldham <danny@lennon.postino.com>
Subject: Re: Learning Perl
Message-Id: <Pine.GSO.3.96.971030080743.28125K-100000@usertest.teleport.com>

On 29 Oct 1997, Danny Aldham wrote:

>  elsif , not elseif . It would be nice if there was a patch to
> the source that would allow both.

There is one, but Larry doesn't like it. To him, 'elseif' doesn't look
right. When it's your language, you can decide how to spell things! :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 08:12:23 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: David McGrath <dmcgrat@earthlink.net>
Subject: Re: Learning Perl
Message-Id: <Pine.GSO.3.96.971030081016.28125L-100000@usertest.teleport.com>

On 30 Oct 1997, David McGrath wrote:

> I'm dealing with a simple if-elseif-else and Perl is telling me of
> syntax errors.

Others have already pointed out that in Perl, the keyword is spelled
'elsif'. But if your copy of Perl didn't tell you that all by itself, you
should see about getting a newer version installed. Without it, you will
probably have other problems with your scripts. The latest version is
5.004; the command 'perl -v' will tell you what version you have. Hope
this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 08:24:11 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrew Taylor <aktaylor@austin.ibm.com>
Subject: Re: perl and gifs or ftp
Message-Id: <Pine.GSO.3.96.971030082324.28125N-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Andrew Taylor wrote:

> I would like to be able to read in a manipulate a gif file in perl! 
> Does anyone know of any perl modules that already allow you to do this?
> 
> Also, I would like my perl script to be able to ftp (not tftp) to an ftp
> server, login as some user/password, and then do puts and gets.  Anyone
> know of any perl modules that already do this?

If there are modules which do what you want, they should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps! 

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 10:35:12 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: Perl module for system-independent "stty raw"?
Message-Id: <34606086.259426575@elf.bri.hp.com>

On Sun, 26 Oct 1997 14:02:43 GMT, over@the.net (dave) wrote:

>ljz@asfast.com (Lloyd Zusman) wrote:
>
>
>>I don't need all the esoteric stty commands.  If I could have
>>system-independent, Perl versions of the "raw", "echo", "-echo", and
>>"sane" stty functions, I'd be happy.
>
>My curses libarary for HPUX provides a raw mode.  There is a curses module for
>Perl but I'm not sure whether it supports raw mode and if it does on which
>platforms.  I'm having trouble with the C curses library on HPUX 10.

I also had hassle building the Curses module under HP-UX 10.20.  The
demos in particular insisted on core-dumping.  I came to the
conclusion that the curses library under HP-UX is 'non-standard' (is
that another way of saying 'broken'?).

Having said all that, provided I am careful to avoid some of the
functions, my perl scripts can now write to curses windows.
----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: 30 Oct 1997 13:38:44 GMT
From: cedwards@infinet.com (Chad Edwards)
Subject: Reading a Binary file.
Message-Id: <63a2l4$t3h@news1.infinet.com>

I am trying to convert a program I wrote in C++ to Perl for Win NT. I 
have a binary file which has X number of records each being the same 
number of bytes long. (59 I believe). In C++, I opened the file as a 
binary file and read the 59 bytes into a character buffer. Then I parsed 
the buffer (some bytes are unsigned integers some are unsigned chars) to 
print the results to a pure TEXT file.

I know that I have to set binmode(filehande) when I open the file, but 
I'm having some problems actually reading/converting the data. I tried 
to read 59 bytes and then use the unpack, but I have yet to be successfull.

Any suggestions?

--


______________________________________________________________________________
http://www.infinet.com/~cedwards 

Official home of RMBL! http://rmbl.ml.org
E-mail dferry@flash.net to be put on the waiting list.
Owner/GM/Manager of the Columbus Capitals
_______________________________________________________________________________



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

Date: 30 Oct 1997 14:49:20 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Reading a Binary file.
Message-Id: <slrn65h7jf.40r.Tom.Grydeland@mitra.phys.uit.no>

On 30 Oct 1997 13:38:44 GMT,
Chad Edwards <cedwards@infinet.com> wrote:
> I tried to read 59 bytes and then use the unpack, but I have yet to be
> successfull.
> 
> Any suggestions?

You seem to be on the right track.  What's the problem?

> http://www.infinet.com/~cedwards 

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Thu, 30 Oct 1997 15:16:51 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Reading a Binary file.
Message-Id: <adelton.878224611@aisa.fi.muni.cz>

cedwards@infinet.com (Chad Edwards) writes:

[...]

> I know that I have to set binmode(filehande) when I open the file, but 
> I'm having some problems actually reading/converting the data. I tried 
> to read 59 bytes and then use the unpack, but I have yet to be successfull.

And what's the command that causes you problem?

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 30 Oct 1997 16:10:19 GMT
From: rparkin@lynx.dac.neu.edu (Robert Parkin)
Subject: Registering a service?
Message-Id: <63abhb$5qq$1@isn.dac.neu.edu>

Does anyone know how to register a service under NT using Perl
or any other means besides in compiled source?

Thanks,

Robert



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

Date: Thu, 30 Oct 1997 10:19:42 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: using -s to get file size
Message-Id: <1997Oct30.101942@ukwit01>

In article <19971029212100.QAA16303@ladder02.news.aol.com>, joydivisin@aol.com (JoyDivisin) writes:
|> Ok, in followup, here's my code:
|>...
|> while ($name = readdir(DOT)) {
|>    open(EP, $name);

   Why do you open this?  You never use it!

|>    if (($pos = index($name,".")) >0) {
|>      @info = stat $name;

   However, the problem is here.  

   You are doing a stat on an entry which is in another directory (from
your original $currdir = "/usr/web/docs/";) but you are referring to it
just by its name, rather than it's full pathname.

   Use:

   @info = stat $currdir/$name;

and things should start working.

|> Anyway, it has a hard time seeing the file size (or uid) of other directories
|>  (not the one it's in). And in a bizarre twist, if I run the program while I'm
|>  in the directory I want it to look in, it'll see the size and uid.

   Not bizarre at all, really.  


-- 
----------- Gordon Lack ----------------- gml4410@ggr.co.uk  ------------
The contents of this message *may* reflect my personal opinion.  They are
*not* intended to reflect those of my employer, or anyone else.


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

Date: Thu, 30 Oct 1997 09:52:35 -0600
From: Brian Lintz <blintz@com.nicorinc>
Subject: Re: using -s to get file size
Message-Id: <3458AD43.6D63@com.nicorinc>

JoyDivisin wrote:
> Ok, in followup, here's my code:
> 
> $currdir = "/usr/web/docs/";
> opendir(DOT, $currdir) || die "Cannot open current dir";
>[...]
> while ($name = readdir(DOT)) {
>    open(EP, $name);

somebody already pointed this out, but you don't ever use EP...

>    if (($pos = index($name,".")) >0) {
>      @info = stat $name;
>      $size = @info[7];
>      $uid = @info[4];

Shouldn't the above be $info[7] and $info[4] ?  not @info[7] and
@info[4]?

>      $total += $size;
>      print "<tr><td>$name</td><td>$size</td><td>$uid</td></tr>\n";
> }
> }
> print "<tr><td></td><td>$total</td></tr>\n";
> closedir(DOT);
> print "</table></body></html>";
> 
> Anyway, it has a hard time seeing the file size (or uid) of other directories
>  (not the one it's in). And in a bizarre twist, if I run the program while I'm
>  in the directory I want it to look in, it'll see the size and uid. Oh, and I
>  am logged in as nobody.

This was also answered already, but if you do a readdir on another
directory 
other than the one the script was called from, you have to refer to the
files 
with the path included.  That's why it works if you list the files in
your 
current directory, but not others...

> Any clues?

That's what I saw ...

-- 
Brian Lintz
WebMaster - Nicor Gas, Inc.


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

Date: 30 Oct 1997 06:01:22 -0600
From: psamuels@sampo.creighton.edu (Peter Samuelson)
Subject: Re: Year2000 problem with localtime();
Message-Id: <639sui$2oh$1@sampo.creighton.edu>

  [Russ Allbery <rra@stanford.edu>
> > On systems where the C library uses a 64 bit time_t, this isn't a
> > problem, so assuming that all systems will be 64 bit by 2038, there
> > won't be a problem.
[Abigail <abigail@fnx.com>]
> Uhm, if I have my application read and write dates, using
> sizeof (time_t) space, I get a problem when sizeof (time_t)
> isn't constant over time.

Yeah, but any time you port something to a different architecture (even
one with the same word size) and need to maintain binary data
compatibility, you have to expect a few headaches.  You can't even
assume sizeof(int) will hold, or how many bytes of alignment might be
needed here or there, and don't even start thinking about float
formats.  time_t is no different.  The only way to avoid all this (not
recommended) is to use "known" word sizes (i.e. #ifdef __alpha #define
INT64 long #define INT32 int #define INT16 short #else etc.).

--
Peter Samuelson
<psamuels@sampo.creighton.edu>


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

Date: Thu, 30 Oct 1997 08:43:14 -0500
From: Henry Hartley <HARTLEH1@westatNOSPAM.com>
Subject: Re: Year2000 problem with localtime();
Message-Id: <34588EF2.505BD394@westatNOSPAM.com>

We have 40 years to deal with the problem if our programs only look at
present or past dates.  What if you are doing something that looks forward
in time, perhaps 50 years forward.  You have to code differently if you are
doing that since there is a problem 40 or so years from now.

Henry

John Moreno wrote:

> Henry Hartley <HARTLEH1@westatNOSPAM.com> wrote:
>
> ] True.  My understanding, however, is that the range for dates in perl
> ] is 2038. Is that not true?  Try running this code:
> ]
> ] #!/usr/local/bin/perl -w
> ] print "Content-type: text/html\n\n";
> ] for ($x==0; $x<43; $x++) {
> ]   $y = $x * (24*60*60*365.24);
> ]   ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
> ] localtime(time+$y);
> ]   $mon = $mon +1;
> ]   $year = $year+1900;
> ]   print "$mon, $mday, $year, $wday, $yday, $isdst, $hour, $min, $sec
> ] \n"; }
> ]
> ] and notice what happens in 2038.  I understand this is not the same as
> ] the year 2000 problem but I can see where it might be a problem.
>
> Well, using MacPerl 2038 is fine but there is a problem with 2040 - in
> any case we have 40+ years to deal with the problem and most systems are
> beginning to go to a 64 bit system, this will probably be complete
> within 15 years.
>
> --
> John Moreno





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

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


Administrivia:

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

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